Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

img: fix incorrect disk sizes in raw format #184

Merged
merged 1 commit into from
Jan 11, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions src/nm_core.h
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,10 @@

#define NM_UNUSED __attribute__((__unused__))

#ifndef S_BLKSIZE
#define S_BLKSIZE 512
#endif

static const int NM_OK;
static const int NM_ERR = -1;

Expand Down
4 changes: 2 additions & 2 deletions src/nm_vm_control.c
Original file line number Diff line number Diff line change
Expand Up @@ -1121,10 +1121,10 @@ nm_str_t nm_vmctl_info(const nm_str_t *name)
memset(&img_info, 0, sizeof(img_info));
stat(drive_path.data, &img_info);

nm_str_append_format(&info, "disk%zu%-7s%s [%.2gGb/%sGb real/virt, %s, "
nm_str_append_format(&info, "disk%zu%-7s%s [%.3gGb/%sGb real/virt, %s, "
"%s] %s\n", n, ":",
nm_vect_str_ctx(&vm.drives, NM_SQL_DRV_NAME + idx_shift),
(double) img_info.st_size / 1073741824,
(double) img_info.st_blocks * S_BLKSIZE / 1073741824,
nm_vect_str_ctx(&vm.drives, NM_SQL_DRV_SIZE + idx_shift),
nm_vect_str_ctx(&vm.drives, NM_SQL_DRV_TYPE + idx_shift),
nm_vect_str_ctx(&vm.drives, NM_SQL_DRV_FMT + idx_shift),
Expand Down
4 changes: 2 additions & 2 deletions src/nm_window.c
Original file line number Diff line number Diff line change
Expand Up @@ -527,10 +527,10 @@ nm_print_vm_info(const nm_str_t *name, const nm_vmctl_data_t *vm, int status)
stat(drive_path.data, &img_info);

nm_str_format(&buf,
"disk%zu%-7s%s [%.2gGb/%sGb real/virt, %s, %s, discard=%s] %s",
"disk%zu%-7s%s [%.3gGb/%sGb real/virt, %s, %s, discard=%s] %s",
n, ":",
nm_vect_str_ctx(&vm_->drives, NM_SQL_DRV_NAME + idx_shift),
(double) img_info.st_size / 1073741824,
(double) img_info.st_blocks * S_BLKSIZE / 1073741824,
nm_vect_str_ctx(&vm_->drives, NM_SQL_DRV_SIZE + idx_shift),
nm_vect_str_ctx(&vm_->drives, NM_SQL_DRV_TYPE + idx_shift),
nm_vect_str_ctx(&vm_->drives, NM_SQL_DRV_FMT + idx_shift),
Expand Down
Loading