From: Fiona Ebner <f.ebner@proxmox.com>
To: Proxmox VE development discussion <pve-devel@lists.proxmox.com>,
Markus Frank <m.frank@proxmox.com>
Subject: Re: [pve-devel] [PATCH qemu-server v11 1/5] add C program to get hardware capabilities from CPUID
Date: Wed, 24 Jul 2024 15:05:49 +0200 [thread overview]
Message-ID: <ea5750da-01de-4f6d-8640-23212b54fe12@proxmox.com> (raw)
In-Reply-To: <20240529122348.1267369-2-m.frank@proxmox.com>
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 <m.frank@proxmox.com>
> Co-authored-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
> Tested-by: Filip Schauer <f.schauer@proxmox.com>
Since there were changes, the Tested-by trailer should be removed.
With the suggested changes below:
Reviewed-by: Fiona Ebner <f.ebner@proxmox.com>
> ---
> 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
next prev parent reply other threads:[~2024-07-24 13:05 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-05-29 12:23 [pve-devel] [PATCH qemu-server/docs/manager v11 0/5] AMD SEV Markus Frank
2024-05-29 12:23 ` [pve-devel] [PATCH qemu-server v11 1/5] add C program to get hardware capabilities from CPUID Markus Frank
2024-07-24 13:05 ` Fiona Ebner [this message]
2024-05-29 12:23 ` [pve-devel] [PATCH qemu-server v11 2/5] config: add AMD SEV support Markus Frank
2024-07-24 13:05 ` Fiona Ebner
2024-05-29 12:23 ` [pve-devel] [PATCH qemu-server v11 3/5] migration: add check_non_migratable_resources function Markus Frank
2024-07-24 13:05 ` Fiona Ebner
2024-05-29 12:23 ` [pve-devel] [PATCH docs v11 4/5] add AMD SEV documentation Markus Frank
2024-05-29 12:23 ` [pve-devel] [PATCH manager v11 5/5] ui: add AMD SEV configuration to Options Markus Frank
2024-07-23 8:11 ` [pve-devel] [PATCH qemu-server/docs/manager v11 0/5] AMD SEV Markus Frank
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=ea5750da-01de-4f6d-8640-23212b54fe12@proxmox.com \
--to=f.ebner@proxmox.com \
--cc=m.frank@proxmox.com \
--cc=pve-devel@lists.proxmox.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox