parent
							
								
									efcd310f88
								
							
						
					
					
						commit
						d2b663602b
					
				
							
								
								
									
										48
									
								
								0004-vgimportclone-fix-importing-PV-without-metadata.patch
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										48
									
								
								0004-vgimportclone-fix-importing-PV-without-metadata.patch
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,48 @@ | ||||
| From 8f7b4456ad93c3907a82fd03d0feceb9785e3bfc Mon Sep 17 00:00:00 2001 | ||||
| From: David Teigland <teigland@redhat.com> | ||||
| Date: Thu, 5 Jan 2023 14:28:31 -0600 | ||||
| Subject: [PATCH 1/3] vgimportclone: fix importing PV without metadata | ||||
| 
 | ||||
| If one of the PVs in the VG does not hold metadata, then the | ||||
| command would fail, thinking that PV was from a different VG. | ||||
| Also add missing free on that error path. | ||||
| 
 | ||||
| (cherry picked from commit c4b898a53eec39bc28b5451e7fde87945303a644) | ||||
| ---
 | ||||
|  tools/vgimportclone.c | 6 ++++-- | ||||
|  1 file changed, 4 insertions(+), 2 deletions(-) | ||||
| 
 | ||||
| diff --git a/tools/vgimportclone.c b/tools/vgimportclone.c
 | ||||
| index 60ef20762..93fa3b18d 100644
 | ||||
| --- a/tools/vgimportclone.c
 | ||||
| +++ b/tools/vgimportclone.c
 | ||||
| @@ -203,7 +203,7 @@ int vgimportclone(struct cmd_context *cmd, int argc, char **argv)
 | ||||
|  	struct device *dev; | ||||
|  	struct device_list *devl; | ||||
|  	struct dm_list other_devs; | ||||
| -	struct volume_group *vg, *error_vg;
 | ||||
| +	struct volume_group *vg, *error_vg = NULL;
 | ||||
|  	const char *vgname; | ||||
|  	char base_vgname[NAME_LEN] = { 0 }; | ||||
|  	char tmp_vgname[NAME_LEN] = { 0 }; | ||||
| @@ -322,7 +322,7 @@ int vgimportclone(struct cmd_context *cmd, int argc, char **argv)
 | ||||
|  			goto out; | ||||
|  		} | ||||
|   | ||||
| -		if (!(vgname = lvmcache_vgname_from_info(info))) {
 | ||||
| +		if (!(vgname = lvmcache_vgname_from_info(info)) || is_orphan_vg(vgname)) {
 | ||||
|  			/* The PV may not have metadata, this will be resolved in | ||||
|  			   the process_each_vg/vg_read at the end. */ | ||||
|  			continue; | ||||
| @@ -503,6 +503,8 @@ retry_name:
 | ||||
|  	} | ||||
|  	ret = ECMD_PROCESSED; | ||||
|  out: | ||||
| +	if (error_vg)
 | ||||
| +		release_vg(error_vg);
 | ||||
|  	unlock_devices_file(cmd); | ||||
|  	return ret; | ||||
|  } | ||||
| -- 
 | ||||
| 2.39.1 | ||||
| 
 | ||||
							
								
								
									
										89
									
								
								0005-lvmdbusd-Move-get_error_msg-to-utils.patch
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										89
									
								
								0005-lvmdbusd-Move-get_error_msg-to-utils.patch
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,89 @@ | ||||
| From 4e34edd6e4e52328dd77b6a55aeadd9b0454c743 Mon Sep 17 00:00:00 2001 | ||||
| From: Tony Asleson <tasleson@redhat.com> | ||||
| Date: Tue, 29 Nov 2022 10:00:39 -0600 | ||||
| Subject: [PATCH 2/3] lvmdbusd: Move get_error_msg to utils | ||||
| 
 | ||||
| Moving this so we can re-use outside of lvm_shell_proxy. | ||||
| 
 | ||||
| (cherry picked from commit 8f60c494515ddccb20e4afb804edb6b9599e65c0) | ||||
| ---
 | ||||
|  daemons/lvmdbusd/lvm_shell_proxy.py.in | 23 +++-------------------- | ||||
|  daemons/lvmdbusd/utils.py              | 17 +++++++++++++++++ | ||||
|  2 files changed, 20 insertions(+), 20 deletions(-) | ||||
| 
 | ||||
| diff --git a/daemons/lvmdbusd/lvm_shell_proxy.py.in b/daemons/lvmdbusd/lvm_shell_proxy.py.in
 | ||||
| index ac6d51e65..37d73218b 100755
 | ||||
| --- a/daemons/lvmdbusd/lvm_shell_proxy.py.in
 | ||||
| +++ b/daemons/lvmdbusd/lvm_shell_proxy.py.in
 | ||||
| @@ -28,7 +28,7 @@ except ImportError:
 | ||||
|   | ||||
|  import lvmdbusd.cfg as cfg | ||||
|  from lvmdbusd.utils import log_debug, log_error, add_no_notify, make_non_block,\ | ||||
| -			read_decoded, extract_stack_trace, LvmBug
 | ||||
| +			read_decoded, extract_stack_trace, LvmBug, get_error_msg
 | ||||
|   | ||||
|  SHELL_PROMPT = "lvm> " | ||||
|   | ||||
| @@ -191,24 +191,7 @@ class LVMShellProxy(object):
 | ||||
|  	def get_last_log(self): | ||||
|  		self._write_cmd('lastlog\n') | ||||
|  		report_json = self._read_response()[1] | ||||
| -		return LVMShellProxy.get_error_msg(report_json)
 | ||||
| -
 | ||||
| -	@staticmethod
 | ||||
| -	def get_error_msg(report_json):
 | ||||
| -		# Get the error message from the returned JSON
 | ||||
| -		if 'log' in report_json:
 | ||||
| -			error_msg = ""
 | ||||
| -			# Walk the entire log array and build an error string
 | ||||
| -			for log_entry in report_json['log']:
 | ||||
| -				if log_entry['log_type'] == "error":
 | ||||
| -					if error_msg:
 | ||||
| -						error_msg += ', ' + log_entry['log_message']
 | ||||
| -					else:
 | ||||
| -						error_msg = log_entry['log_message']
 | ||||
| -
 | ||||
| -			return error_msg
 | ||||
| -
 | ||||
| -		return None
 | ||||
| +		return get_error_msg(report_json)
 | ||||
|   | ||||
|  	def call_lvm(self, argv, debug=False): | ||||
|  		rc = 1 | ||||
| @@ -245,7 +228,7 @@ class LVMShellProxy(object):
 | ||||
|  				# report json too. | ||||
|  				error_msg = self.get_last_log() | ||||
|  				if error_msg is None: | ||||
| -					error_msg = LVMShellProxy.get_error_msg(report_json)
 | ||||
| +					error_msg = get_error_msg(report_json)
 | ||||
|  					if error_msg is None: | ||||
|  						error_msg = 'No error reason provided! (missing "log" section)' | ||||
|   | ||||
| diff --git a/daemons/lvmdbusd/utils.py b/daemons/lvmdbusd/utils.py
 | ||||
| index 5aecb1fff..0b81591b2 100644
 | ||||
| --- a/daemons/lvmdbusd/utils.py
 | ||||
| +++ b/daemons/lvmdbusd/utils.py
 | ||||
| @@ -859,3 +859,20 @@ class LvmDebugData:
 | ||||
|  		self._close_fd() | ||||
|  		# In case lvm_complete doesn't get called. | ||||
|  		self._remove_file() | ||||
| +
 | ||||
| +
 | ||||
| +def get_error_msg(report_json):
 | ||||
| +	# Get the error message from the returned JSON
 | ||||
| +	if 'log' in report_json:
 | ||||
| +		error_msg = ""
 | ||||
| +		# Walk the entire log array and build an error string
 | ||||
| +		for log_entry in report_json['log']:
 | ||||
| +			if log_entry['log_type'] == "error":
 | ||||
| +				if error_msg:
 | ||||
| +					error_msg += ', ' + log_entry['log_message']
 | ||||
| +				else:
 | ||||
| +					error_msg = log_entry['log_message']
 | ||||
| +
 | ||||
| +		return error_msg
 | ||||
| +
 | ||||
| +	return None
 | ||||
| -- 
 | ||||
| 2.39.1 | ||||
| 
 | ||||
| @ -0,0 +1,79 @@ | ||||
| From 0441d340e752427d0d355a85e5e5e465e911a102 Mon Sep 17 00:00:00 2001 | ||||
| From: Tony Asleson <tasleson@redhat.com> | ||||
| Date: Tue, 29 Nov 2022 10:04:17 -0600 | ||||
| Subject: [PATCH 3/3] lvmdbusd: Add command_log_selection to command line | ||||
| 
 | ||||
| Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=2145114 | ||||
| (cherry picked from commit e63b0c7262f50ab43fcde1c50b6d880acab68407) | ||||
| ---
 | ||||
|  daemons/lvmdbusd/cmdhandler.py | 33 +++++++++++++++++---------------- | ||||
|  1 file changed, 17 insertions(+), 16 deletions(-) | ||||
| 
 | ||||
| diff --git a/daemons/lvmdbusd/cmdhandler.py b/daemons/lvmdbusd/cmdhandler.py
 | ||||
| index 0c7bd8528..9a76db4c9 100644
 | ||||
| --- a/daemons/lvmdbusd/cmdhandler.py
 | ||||
| +++ b/daemons/lvmdbusd/cmdhandler.py
 | ||||
| @@ -17,7 +17,7 @@ import os
 | ||||
|   | ||||
|  from lvmdbusd import cfg | ||||
|  from lvmdbusd.utils import pv_dest_ranges, log_debug, log_error, add_no_notify,\ | ||||
| -			make_non_block, read_decoded, extract_stack_trace, LvmBug, add_config_option
 | ||||
| +			make_non_block, read_decoded, extract_stack_trace, LvmBug, add_config_option, get_error_msg
 | ||||
|  from lvmdbusd.lvm_shell_proxy import LVMShellProxy | ||||
|   | ||||
|  try: | ||||
| @@ -121,6 +121,9 @@ def call_lvm(command, debug=False, line_cb=None,
 | ||||
|  	command.insert(0, cfg.LVM_CMD) | ||||
|  	command = add_no_notify(command) | ||||
|   | ||||
| +	# Ensure we get an error message when we fork & exec the lvm command line
 | ||||
| +	command = add_config_option(command, "--config", 'log/command_log_selection="log_context!=''"')
 | ||||
| +
 | ||||
|  	process = Popen(command, stdout=PIPE, stderr=PIPE, close_fds=True, | ||||
|  					env=os.environ) | ||||
|   | ||||
| @@ -167,7 +170,17 @@ def call_lvm(command, debug=False, line_cb=None,
 | ||||
|  		if debug or (process.returncode != 0 and (process.returncode != 5 and "fullreport" in command)): | ||||
|  			_debug_c(command, process.returncode, (stdout_text, stderr_text)) | ||||
|   | ||||
| -		return process.returncode, stdout_text, stderr_text
 | ||||
| +		try:
 | ||||
| +			report_json = json.loads(stdout_text)
 | ||||
| +		except json.decoder.JSONDecodeError:
 | ||||
| +			# Some lvm commands don't return json even though we are asking for it to do so.
 | ||||
| +			return process.returncode, stdout_text, stderr_text
 | ||||
| +
 | ||||
| +		error_msg = get_error_msg(report_json)
 | ||||
| +		if error_msg:
 | ||||
| +			stderr_text += error_msg
 | ||||
| +
 | ||||
| +		return process.returncode, report_json, stderr_text
 | ||||
|  	else: | ||||
|  		if cfg.run.value == 0: | ||||
|  			raise SystemExit | ||||
| @@ -619,20 +632,8 @@ def lvm_full_report_json():
 | ||||
|  	rc, out, err = call(cmd) | ||||
|  	# When we have an exported vg the exit code of lvs or fullreport will be 5 | ||||
|  	if rc == 0 or rc == 5: | ||||
| -		# If the 'call' implementation is lvmshell, the out is a dictionary as lvmshell has to
 | ||||
| -		# parse the output to get the exit value.  When doing fork & exec, out is a string
 | ||||
| -		# representing the JSON.  TODO: Make this consistent between implementations.
 | ||||
| -		if cfg.SHELL_IN_USE:
 | ||||
| -			assert(type(out) == dict)
 | ||||
| -			return out
 | ||||
| -		else:
 | ||||
| -			try:
 | ||||
| -				return json.loads(out)
 | ||||
| -			except json.decoder.JSONDecodeError as joe:
 | ||||
| -				log_error("JSONDecodeError %s, \n JSON=\n%s\n" %
 | ||||
| -							(str(joe), out))
 | ||||
| -				raise LvmBug("'fullreport' returned invalid JSON")
 | ||||
| -
 | ||||
| +		assert(type(out) == dict)
 | ||||
| +		return out
 | ||||
|  	raise LvmBug("'fullreport' exited with code '%d'" % rc) | ||||
|   | ||||
|   | ||||
| -- 
 | ||||
| 2.39.1 | ||||
| 
 | ||||
							
								
								
									
										14
									
								
								lvm2.spec
									
									
									
									
									
								
							
							
						
						
									
										14
									
								
								lvm2.spec
									
									
									
									
									
								
							| @ -63,7 +63,7 @@ Version: 2.03.17 | ||||
| #Release: 0.1.20211115git%{shortcommit}%{?dist}%{?rel_suffix} | ||||
| Release: 4%{?dist}%{?rel_suffix} | ||||
| %else | ||||
| Release: 4%{?dist}%{?rel_suffix} | ||||
| Release: 5%{?dist}%{?rel_suffix} | ||||
| %endif | ||||
| License: GPLv2 | ||||
| URL: http://sourceware.org/lvm2 | ||||
| @ -78,6 +78,11 @@ Patch1: 0001-device_id-fix-segfault-verifying-serial-for-non-pv.patch | ||||
| Patch2: 0002-lvextend-fix-overprovisioning-check-for-thin-lvs.patch | ||||
| # BZ 2157591: | ||||
| Patch3: 0003-lvresize-fix-cryptsetup-resize-in-helper.patch | ||||
| # BZ 2158619: | ||||
| Patch4: 0004-vgimportclone-fix-importing-PV-without-metadata.patch | ||||
| # BZ 2164044: | ||||
| Patch5: 0005-lvmdbusd-Move-get_error_msg-to-utils.patch | ||||
| Patch6: 0006-lvmdbusd-Add-command_log_selection-to-command-line.patch | ||||
| 
 | ||||
| BuildRequires: make | ||||
| BuildRequires: gcc | ||||
| @ -141,6 +146,9 @@ or more physical volumes and creating one or more logical volumes | ||||
| %patch1 -p1 -b .backup1 | ||||
| %patch2 -p1 -b .backup2 | ||||
| %patch3 -p1 -b .backup3 | ||||
| %patch4 -p1 -b .backup4 | ||||
| %patch5 -p1 -b .backup5 | ||||
| %patch6 -p1 -b .backup6 | ||||
| 
 | ||||
| %build | ||||
| %global _default_pid_dir /run | ||||
| @ -712,6 +720,10 @@ An extensive functional testsuite for LVM2. | ||||
| %endif | ||||
| 
 | ||||
| %changelog | ||||
| * Fri Jan 27 2023 Marian Csontos <mcsontos@redhat.com> - 2.03.17-5 | ||||
| - Fix vgimportclone fail if PV has no metadata. | ||||
| - Fix lvmdbusd missing stderr for commands not returning JSON. | ||||
| 
 | ||||
| * Fri Jan 06 2023 Marian Csontos <mcsontos@redhat.com> - 2.03.17-4 | ||||
| - Fix missing warning on thin pool over provisioning. | ||||
| - Fix infinite recursion in lvresize_fs_helper when resizing LUKS device. | ||||
|  | ||||
		Loading…
	
		Reference in New Issue
	
	Block a user