mirror of
https://git.proxmox.com/git/qemu-server
synced 2025-06-14 13:26:24 +00:00
query-machine-capabilities: fix indentation
do not propagate that absolute mess of mixing tabs and spaces to new programs that ain't perl and thus doesn't need to suffer. Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
This commit is contained in:
parent
c9eee44b47
commit
bd62724fcd
@ -12,8 +12,8 @@ int main() {
|
|||||||
// https://en.wikipedia.org/wiki/CPUID#EAX=8000001Fh:_Encrypted_Memory_Capabilities
|
// https://en.wikipedia.org/wiki/CPUID#EAX=8000001Fh:_Encrypted_Memory_Capabilities
|
||||||
uint32_t query_function = 0x8000001F;
|
uint32_t query_function = 0x8000001F;
|
||||||
asm volatile("cpuid"
|
asm volatile("cpuid"
|
||||||
: "=a"(eax), "=b"(ebx), "=c"(ecx), "=d"(edx)
|
: "=a"(eax), "=b"(ebx), "=c"(ecx), "=d"(edx)
|
||||||
: "0"(query_function)
|
: "0"(query_function)
|
||||||
);
|
);
|
||||||
|
|
||||||
bool sev_support = (eax & (1<<1)) != 0;
|
bool sev_support = (eax & (1<<1)) != 0;
|
||||||
@ -28,51 +28,51 @@ int main() {
|
|||||||
struct stat statbuf;
|
struct stat statbuf;
|
||||||
int ret = stat(path, &statbuf);
|
int ret = stat(path, &statbuf);
|
||||||
if (ret == 0) {
|
if (ret == 0) {
|
||||||
if (!S_ISDIR(statbuf.st_mode)) {
|
if (!S_ISDIR(statbuf.st_mode)) {
|
||||||
printf("Path %s is not a directory.\n", path);
|
printf("Path %s is not a directory.\n", path);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
} else if (errno == ENOENT) {
|
} else if (errno == ENOENT) {
|
||||||
if (mkdir(path, 0755) != 0) {
|
if (mkdir(path, 0755) != 0) {
|
||||||
printf("Error creating directory %s: %s\n", path, strerror(errno));
|
printf("Error creating directory %s: %s\n", path, strerror(errno));
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
printf("Error checking path %s: %s\n", path, strerror(errno));
|
printf("Error checking path %s: %s\n", path, strerror(errno));
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
FILE *file;
|
FILE *file;
|
||||||
const char *filename = "/run/qemu-server/host-hw-capabilities.json";
|
const char *filename = "/run/qemu-server/host-hw-capabilities.json";
|
||||||
file = fopen(filename, "w");
|
file = fopen(filename, "w");
|
||||||
if (file == NULL) {
|
if (file == NULL) {
|
||||||
perror("Error opening file");
|
perror("Error opening file");
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
ret = fprintf(file,
|
ret = fprintf(file,
|
||||||
"{"
|
"{"
|
||||||
" \"amd-sev\": {"
|
" \"amd-sev\": {"
|
||||||
" \"cbitpos\": %u,"
|
" \"cbitpos\": %u,"
|
||||||
" \"reduced-phys-bits\": %u,"
|
" \"reduced-phys-bits\": %u,"
|
||||||
" \"sev-support\": %s,"
|
" \"sev-support\": %s,"
|
||||||
" \"sev-support-es\": %s,"
|
" \"sev-support-es\": %s,"
|
||||||
" \"sev-support-snp\": %s"
|
" \"sev-support-snp\": %s"
|
||||||
" }"
|
" }"
|
||||||
" }\n",
|
" }\n",
|
||||||
cbitpos,
|
cbitpos,
|
||||||
reduced_phys_bits,
|
reduced_phys_bits,
|
||||||
sev_support ? "true" : "false",
|
sev_support ? "true" : "false",
|
||||||
sev_es_support ? "true" : "false",
|
sev_es_support ? "true" : "false",
|
||||||
sev_snp_support ? "true" : "false"
|
sev_snp_support ? "true" : "false"
|
||||||
);
|
);
|
||||||
if (ret < 0) {
|
if (ret < 0) {
|
||||||
printf("Error writing to file %s: %s\n", path, strerror(errno));
|
printf("Error writing to file %s: %s\n", path, strerror(errno));
|
||||||
}
|
}
|
||||||
|
|
||||||
ret = fclose(file);
|
ret = fclose(file);
|
||||||
if (ret != 0) {
|
if (ret != 0) {
|
||||||
printf("Error closing file %s: %s\n", path, strerror(errno));
|
printf("Error closing file %s: %s\n", path, strerror(errno));
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
Loading…
Reference in New Issue
Block a user