Re: [PATCH] vmware: Improve output when we fail to read vmware 'vmsn' file

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 2023/07/06 23:53, Dave Wysochanski wrote:
> Today if crash fails to read some structure in a vmware 'vmsn' file,
> it will throw an "No such file or directory" message.  Such a generic
> message does not give any clue as to the problem, but instead sounds
> like the file may not exist when it does, for example:
>    $ crash ./vmcore.vmsn  ./vmlinux
> 
>    crash 8.0.3
>    ...
> 
>    crash: vmw: Failed to read './vmcore.vmsn': [Error 2] No such file or directory
> 
>    crash: ./vmcore.vmsn: initialization failed
> 
>    $ ls -l ./vmcore.vmsn
>    -rwxrwxrwx. 7 myuser mygroup 12128999 Jul  4 07:21 ./vmcore.vmsn
> 
> Improve the above error message so we at least know which portion
> of the file crash had difficulty reading.  After this patch, the
> above error looks like:
>    crash: vmw: Failed to read 'cptgroupdesc' from file './vmcore.vmsn': [Error 2] No such file or directory
> 
> Signed-off-by: Dave Wysochanski <dwysocha@xxxxxxxxxx>

Thank you for the improvement.

Acked-by: Kazuhito Hagio <k-hagio-ab@xxxxxxx>

Thanks,
Kazu

> ---
>   vmware_guestdump.c |  8 ++++----
>   vmware_vmss.c      | 24 ++++++++++++------------
>   2 files changed, 16 insertions(+), 16 deletions(-)
> 
> diff --git a/vmware_guestdump.c b/vmware_guestdump.c
> index cf818e588a60..5be26c8e2e90 100644
> --- a/vmware_guestdump.c
> +++ b/vmware_guestdump.c
> @@ -117,8 +117,8 @@ is_vmware_guestdump(char *filename)
>           }
>   
>   	if (fread(&hdr, sizeof(struct guestdumpheader), 1, fp) != 1) {
> -		error(INFO, LOGPRX"Failed to read '%s': [Error %d] %s\n",
> -		      filename, errno, strerror(errno));
> +		error(INFO, LOGPRX"Failed to read '%s' from file '%s': [Error %d] %s\n",
> +		      "guestdumpheader", filename, errno, strerror(errno));
>   		fclose(fp);
>   		return FALSE;
>   	}
> @@ -204,8 +204,8 @@ vmware_guestdump_init(char *filename, FILE *ofp)
>   
>   	for (i = 0; i < vmss.num_vcpus; i++) {
>   		if (fread(&vs, sizeof(struct vcpu_state), 1, fp) != 1) {
> -			error(INFO, LOGPRX"Failed to read '%s': [Error %d] %s\n",
> -					filename, errno, strerror(errno));
> +			error(INFO, LOGPRX"Failed to read '%s' from file '%s': [Error %d] %s\n",
> +					"vcpu_state", filename, errno, strerror(errno));
>   			result = FALSE;
>   			goto exit;
>   		}
> diff --git a/vmware_vmss.c b/vmware_vmss.c
> index f6c5f32ea4c0..8121ab64a99a 100644
> --- a/vmware_vmss.c
> +++ b/vmware_vmss.c
> @@ -39,8 +39,8 @@ is_vmware_vmss(char *filename)
>           }
>   
>   	if (fread(&hdr, sizeof(cptdumpheader), 1, fp) != 1) {
> -		error(INFO, LOGPRX"Failed to read '%s': [Error %d] %s\n",
> -		      filename, errno, strerror(errno));
> +		error(INFO, LOGPRX"Failed to read '%s' from file '%s': [Error %d] %s\n",
> +		      "cptdumpheader", filename, errno, strerror(errno));
>   		fclose(fp);
>   		return FALSE;
>   	}
> @@ -86,8 +86,8 @@ vmware_vmss_init(char *filename, FILE *ofp)
>           }
>   
>   	if (fread(&hdr, sizeof(cptdumpheader), 1, fp) != 1) {
> -		error(INFO, LOGPRX"Failed to read '%s': %s [Error %d] %s\n",
> -                      filename, errno, strerror(errno));
> +		error(INFO, LOGPRX"Failed to read '%s' from file '%s': [Error %d] %s\n",
> +		      "cptdumpheader", filename, errno, strerror(errno));
>   		result = FALSE;
>   		goto exit;
>   	}
> @@ -112,8 +112,8 @@ vmware_vmss_init(char *filename, FILE *ofp)
>   	}
>   
>   	if (fread(grps, sizeof(cptgroupdesc), grpsize, fp) != grpsize) {
> -		error(INFO, LOGPRX"Failed to read '%s': [Error %d] %s\n",
> -		      filename, errno, strerror(errno));
> +		error(INFO, LOGPRX"Failed to read '%s' from file '%s': [Error %d] %s\n",
> +		      "cptgroupdesc", filename, errno, strerror(errno));
>   		result = FALSE;
>   		goto exit;
>   	}
> @@ -225,8 +225,8 @@ vmware_vmss_init(char *filename, FILE *ofp)
>   					   idx[0] < vmss.num_vcpus) {
>   					int cpu = idx[0];
>   					if (fread(vmss.regs64[cpu], VMW_GPREGS_SIZE, 1, fp) != 1) {
> -						error(INFO, LOGPRX"Failed to read '%s': [Error %d] %s\n",
> -						      filename, errno, strerror(errno));
> +						error(INFO, LOGPRX"Failed to read '%s' from file '%s': [Error %d] %s\n",
> +						      name, filename, errno, strerror(errno));
>   						break;
>   					}
>   					DEBUG_PARSE_PRINT((ofp, "\n"));
> @@ -237,8 +237,8 @@ vmware_vmss_init(char *filename, FILE *ofp)
>   					int cpu = idx[0];
>   					DEBUG_PARSE_PRINT((ofp, "\t=> "));
>   					if (fread(&vmss.regs64[cpu]->cr[0], VMW_CR64_SIZE, 1, fp) != 1) {
> -						error(INFO, LOGPRX"Failed to read '%s': [Error %d] %s\n",
> -						      filename, errno, strerror(errno));
> +						error(INFO, LOGPRX"Failed to read '%s' from file '%s': [Error %d] %s\n",
> +						      name, filename, errno, strerror(errno));
>   						break;
>   					}
>   					for (j = 0; j < VMW_CR64_SIZE / 8; j++)
> @@ -257,8 +257,8 @@ vmware_vmss_init(char *filename, FILE *ofp)
>   						break;
>   					}
>   					if (fread(&idtr, sizeof(idtr), 1, fp) != 1) {
> -						error(INFO, LOGPRX"Failed to read '%s': [Error %d] %s\n",
> -						      filename, errno, strerror(errno));
> +						error(INFO, LOGPRX"Failed to read '%s' from file '%s': [Error %d] %s\n",
> +						      name, filename, errno, strerror(errno));
>   						break;
>   					}
>   					DEBUG_PARSE_PRINT((ofp, "\n"));
--
Crash-utility mailing list
Crash-utility@xxxxxxxxxx
https://listman.redhat.com/mailman/listinfo/crash-utility
Contribution Guidelines: https://github.com/crash-utility/crash/wiki




[Index of Archives]     [Fedora Development]     [Fedora Desktop]     [Fedora SELinux]     [Yosemite News]     [KDE Users]     [Fedora Tools]

 

Powered by Linux