From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from firstgate.proxmox.com (firstgate.proxmox.com [IPv6:2a01:7e0:0:424::9]) by lore.proxmox.com (Postfix) with ESMTPS id 745121FF2C7 for ; Wed, 24 Jul 2024 15:05:48 +0200 (CEST) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id F1DFD1C3B4; Wed, 24 Jul 2024 15:06:22 +0200 (CEST) Message-ID: Date: Wed, 24 Jul 2024 15:05:49 +0200 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird To: Proxmox VE development discussion , Markus Frank References: <20240529122348.1267369-1-m.frank@proxmox.com> <20240529122348.1267369-2-m.frank@proxmox.com> Content-Language: en-US From: Fiona Ebner In-Reply-To: <20240529122348.1267369-2-m.frank@proxmox.com> X-SPAM-LEVEL: Spam detection results: 0 AWL -0.060 Adjusted score from AWL reputation of From: address BAYES_00 -1.9 Bayes spam probability is 0 to 1% DMARC_MISSING 0.1 Missing DMARC policy KAM_DMARC_STATUS 0.01 Test Rule for DKIM or SPF Failure with Strict Alignment SPF_HELO_NONE 0.001 SPF: HELO does not publish an SPF Record SPF_PASS -0.001 SPF: sender matches SPF record Subject: Re: [pve-devel] [PATCH qemu-server v11 1/5] add C program to get hardware capabilities from CPUID X-BeenThere: pve-devel@lists.proxmox.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Proxmox VE development discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: Proxmox VE development discussion Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: pve-devel-bounces@lists.proxmox.com Sender: "pve-devel" Am 29.05.24 um 14:23 schrieb Markus Frank: > Implement a C program that extracts AMD SEV hardware information such > as reduced-phys-bios and cbitpos from CPUID at boot time, looks if > SEV, SEV-ES & SEV-SNP are enabled, and outputs these details as JSON > to /run/qemu-server/host-hw-capabilities.json > > This programm can also be used to read and save other hardware Typo: should be "program" > information at boot time. > > Signed-off-by: Markus Frank > Co-authored-by: Thomas Lamprecht > Tested-by: Filip Schauer Since there were changes, the Tested-by trailer should be removed. With the suggested changes below: Reviewed-by: Fiona Ebner > --- > changes v11: > * removed systemd service * improved error handling > + ret = fprintf(file, > + "{" > + " \"amd-sev\": {" > + " \"cbitpos\": %u," > + " \"reduced-phys-bits\": %u," > + " \"sev-support\": %s," > + " \"sev-support-es\": %s," > + " \"sev-support-snp\": %s" > + " }" > + " }\n", > + cbitpos, > + reduced_phys_bits, > + sev_support ? "true" : "false", > + sev_es_support ? "true" : "false", > + sev_snp_support ? "true" : "false" > + ); > + if (ret == -1) { "man 3 fprintf" states: > If an output error is encountered, a negative value is returned." and while a quick glance at the source code shows that -1 is used in many places, I'm not sure that's true for all error paths. Let's check for < 0 instead. > + printf("Error writing to file %s: %s\n", path, strerror(errno)); > + } > + > + ret = fclose(file); Nit: "man 3 fclose" states: > Upon successful completion, 0 is returned. Otherwise, EOF is returned > and errno is set to indicate the error. While EOF is defined to be -1 in stdio.h, it's better to use the constant explicitly (or could also use ret != 0). > + if (ret == -1) { > + printf("Error closing file %s: %s\n", path, strerror(errno)); > + } > + > + return 0; > +} _______________________________________________ pve-devel mailing list pve-devel@lists.proxmox.com https://lists.proxmox.com/cgi-bin/mailman/listinfo/pve-devel