From: Fiona Ebner <f.ebner@proxmox.com>
To: pve-devel@lists.proxmox.com
Subject: [pve-devel] [PATCH v2 qemu 2/2] code style: some more coccinelle fixes
Date: Mon, 24 Feb 2025 15:57:05 +0100 [thread overview]
Message-ID: <20250224145705.140576-2-f.ebner@proxmox.com> (raw)
In-Reply-To: <20250224145705.140576-1-f.ebner@proxmox.com>
Below are the commands that generated the changes along with the
rationale:
command: spatch --in-place scripts/coccinelle/error_propagate_null.cocci pve-backup.c
rationale: error_propagate() already checks for NULL in its second
argument
command: spatch --in-place scripts/coccinelle/round.cocci vma-reader.c vma-writer.c
rationale: DIV_ROUND_UP() macro is more readable than the expanded
calculation
Signed-off-by: Fiona Ebner <f.ebner@proxmox.com>
---
New in v2.
An additional suggestion would've been to use
-vmar->head_data = g_malloc(sizeof(VmaHeader));
+vmar->head_data = g_new(VmaHeader, 1);
in vma-reader.c, but head_data is an 'unsigned char *', so that
would require adding a cast too and doesn't actually seem cleaner.
...VE-Backup-add-vma-backup-format-code.patch | 20 +++++++++----------
...ckup-Proxmox-backup-patches-for-QEMU.patch | 12 +++++------
...igrate-dirty-bitmap-state-via-savevm.patch | 4 ++--
.../0044-PVE-backup-add-fleecing-option.patch | 4 ++--
...ve-error-when-copy-before-write-fail.patch | 2 +-
...up-fixup-error-handling-for-fleecing.patch | 2 +-
...r-out-setting-up-snapshot-access-for.patch | 2 +-
...device-name-in-device-info-structure.patch | 6 +++---
...de-device-name-in-error-when-setting.patch | 2 +-
9 files changed, 25 insertions(+), 29 deletions(-)
diff --git a/debian/patches/pve/0027-PVE-Backup-add-vma-backup-format-code.patch b/debian/patches/pve/0027-PVE-Backup-add-vma-backup-format-code.patch
index 186cbf7..aa60306 100644
--- a/debian/patches/pve/0027-PVE-Backup-add-vma-backup-format-code.patch
+++ b/debian/patches/pve/0027-PVE-Backup-add-vma-backup-format-code.patch
@@ -16,11 +16,11 @@ Signed-off-by: Fiona Ebner <f.ebner@proxmox.com>
---
block/meson.build | 2 +
meson.build | 5 +
- vma-reader.c | 868 ++++++++++++++++++++++++++++++++++++++++++
- vma-writer.c | 817 ++++++++++++++++++++++++++++++++++++++++
+ vma-reader.c | 867 ++++++++++++++++++++++++++++++++++++++++++
+ vma-writer.c | 816 ++++++++++++++++++++++++++++++++++++++++
vma.c | 941 ++++++++++++++++++++++++++++++++++++++++++++++
vma.h | 150 ++++++++
- 6 files changed, 2783 insertions(+)
+ 6 files changed, 2781 insertions(+)
create mode 100644 vma-reader.c
create mode 100644 vma-writer.c
create mode 100644 vma.c
@@ -64,10 +64,10 @@ index 147097c652..b9b673c271 100644
foreach exe: [ 'qemu-img', 'qemu-io', 'qemu-nbd', 'qemu-storage-daemon']
diff --git a/vma-reader.c b/vma-reader.c
new file mode 100644
-index 0000000000..65015d2e1e
+index 0000000000..bb65ad313c
--- /dev/null
+++ b/vma-reader.c
-@@ -0,0 +1,868 @@
+@@ -0,0 +1,867 @@
+/*
+ * VMA: Virtual Machine Archive
+ *
@@ -883,8 +883,7 @@ index 0000000000..65015d2e1e
+
+ int64_t cluster_num, end;
+
-+ end = (vmar->devinfo[i].size + VMA_CLUSTER_SIZE - 1) /
-+ VMA_CLUSTER_SIZE;
++ end = DIV_ROUND_UP(vmar->devinfo[i].size, VMA_CLUSTER_SIZE);
+
+ for (cluster_num = 0; cluster_num < end; cluster_num++) {
+ if (!vma_reader_get_bitmap(rstate, cluster_num)) {
@@ -938,10 +937,10 @@ index 0000000000..65015d2e1e
+
diff --git a/vma-writer.c b/vma-writer.c
new file mode 100644
-index 0000000000..a466652a5d
+index 0000000000..3f489092df
--- /dev/null
+++ b/vma-writer.c
-@@ -0,0 +1,817 @@
+@@ -0,0 +1,816 @@
+/*
+ * VMA: Virtual Machine Archive
+ *
@@ -1135,8 +1134,7 @@ index 0000000000..a466652a5d
+ vmaw->stream_info[n].devname = g_strdup(devname);
+ vmaw->stream_info[n].size = size;
+
-+ vmaw->stream_info[n].cluster_count = (size + VMA_CLUSTER_SIZE - 1) /
-+ VMA_CLUSTER_SIZE;
++ vmaw->stream_info[n].cluster_count = DIV_ROUND_UP(size, VMA_CLUSTER_SIZE);
+
+ vmaw->stream_count = n;
+
diff --git a/debian/patches/pve/0030-PVE-Backup-Proxmox-backup-patches-for-QEMU.patch b/debian/patches/pve/0030-PVE-Backup-Proxmox-backup-patches-for-QEMU.patch
index 0180f85..66372a5 100644
--- a/debian/patches/pve/0030-PVE-Backup-Proxmox-backup-patches-for-QEMU.patch
+++ b/debian/patches/pve/0030-PVE-Backup-Proxmox-backup-patches-for-QEMU.patch
@@ -94,11 +94,11 @@ Signed-off-by: Fiona Ebner <f.ebner@proxmox.com>
monitor/hmp-cmds.c | 72 +++
proxmox-backup-client.c | 146 +++++
proxmox-backup-client.h | 60 ++
- pve-backup.c | 1092 ++++++++++++++++++++++++++++++++
+ pve-backup.c | 1090 ++++++++++++++++++++++++++++++++
qapi/block-core.json | 233 +++++++
qapi/common.json | 14 +
qapi/machine.json | 16 +-
- 14 files changed, 1711 insertions(+), 14 deletions(-)
+ 14 files changed, 1709 insertions(+), 14 deletions(-)
create mode 100644 proxmox-backup-client.c
create mode 100644 proxmox-backup-client.h
create mode 100644 pve-backup.c
@@ -586,10 +586,10 @@ index 0000000000..8cbf645b2c
+#endif /* PROXMOX_BACKUP_CLIENT_H */
diff --git a/pve-backup.c b/pve-backup.c
new file mode 100644
-index 0000000000..9f83ecb310
+index 0000000000..fea0152de0
--- /dev/null
+++ b/pve-backup.c
-@@ -0,0 +1,1092 @@
+@@ -0,0 +1,1090 @@
+#include "proxmox-backup-client.h"
+#include "vma.h"
+
@@ -1440,9 +1440,7 @@ index 0000000000..9f83ecb310
+ } else if (format == BACKUP_FORMAT_VMA) {
+ vmaw = vma_writer_create(backup_file, uuid, &local_err);
+ if (!vmaw) {
-+ if (local_err) {
-+ error_propagate(errp, local_err);
-+ }
++ error_propagate(errp, local_err);
+ goto err_mutex;
+ }
+
diff --git a/debian/patches/pve/0034-PVE-Migrate-dirty-bitmap-state-via-savevm.patch b/debian/patches/pve/0034-PVE-Migrate-dirty-bitmap-state-via-savevm.patch
index cbd90cc..b794959 100644
--- a/debian/patches/pve/0034-PVE-Migrate-dirty-bitmap-state-via-savevm.patch
+++ b/debian/patches/pve/0034-PVE-Migrate-dirty-bitmap-state-via-savevm.patch
@@ -180,10 +180,10 @@ index 0000000000..a97187e4d7
+ NULL);
+}
diff --git a/pve-backup.c b/pve-backup.c
-index 9f83ecb310..57477f7f2a 100644
+index fea0152de0..faa6a9b93c 100644
--- a/pve-backup.c
+++ b/pve-backup.c
-@@ -1085,6 +1085,7 @@ ProxmoxSupportStatus *qmp_query_proxmox_support(Error **errp)
+@@ -1083,6 +1083,7 @@ ProxmoxSupportStatus *qmp_query_proxmox_support(Error **errp)
ret->pbs_library_version = g_strdup(proxmox_backup_qemu_version());
ret->pbs_dirty_bitmap = true;
ret->pbs_dirty_bitmap_savevm = true;
diff --git a/debian/patches/pve/0044-PVE-backup-add-fleecing-option.patch b/debian/patches/pve/0044-PVE-backup-add-fleecing-option.patch
index aa43103..8663a33 100644
--- a/debian/patches/pve/0044-PVE-backup-add-fleecing-option.patch
+++ b/debian/patches/pve/0044-PVE-backup-add-fleecing-option.patch
@@ -80,7 +80,7 @@ index 439a7a14c8..d0e7771dcc 100644
hmp_handle_error(mon, error);
diff --git a/pve-backup.c b/pve-backup.c
-index 57477f7f2a..0f098000dd 100644
+index faa6a9b93c..4b0820c8a7 100644
--- a/pve-backup.c
+++ b/pve-backup.c
@@ -7,9 +7,11 @@
@@ -286,7 +286,7 @@ index 57477f7f2a..0f098000dd 100644
bdrv_graph_co_rdunlock();
if (local_err) {
error_propagate(errp, local_err);
-@@ -1089,5 +1217,6 @@ ProxmoxSupportStatus *qmp_query_proxmox_support(Error **errp)
+@@ -1087,5 +1215,6 @@ ProxmoxSupportStatus *qmp_query_proxmox_support(Error **errp)
ret->query_bitmap_info = true;
ret->pbs_masterkey = true;
ret->backup_max_workers = true;
diff --git a/debian/patches/pve/0045-PVE-backup-improve-error-when-copy-before-write-fail.patch b/debian/patches/pve/0045-PVE-backup-improve-error-when-copy-before-write-fail.patch
index 8c51a39..dbbf64a 100644
--- a/debian/patches/pve/0045-PVE-backup-improve-error-when-copy-before-write-fail.patch
+++ b/debian/patches/pve/0045-PVE-backup-improve-error-when-copy-before-write-fail.patch
@@ -96,7 +96,7 @@ index 2a5d4ba693..969da3620f 100644
#endif /* COPY_BEFORE_WRITE_H */
diff --git a/pve-backup.c b/pve-backup.c
-index 0f098000dd..75da1dc051 100644
+index 4b0820c8a7..81697d9bf9 100644
--- a/pve-backup.c
+++ b/pve-backup.c
@@ -374,6 +374,15 @@ static void pvebackup_complete_cb(void *opaque, int ret)
diff --git a/debian/patches/pve/0046-PVE-backup-fixup-error-handling-for-fleecing.patch b/debian/patches/pve/0046-PVE-backup-fixup-error-handling-for-fleecing.patch
index 9a8ac00..1b4fdd2 100644
--- a/debian/patches/pve/0046-PVE-backup-fixup-error-handling-for-fleecing.patch
+++ b/debian/patches/pve/0046-PVE-backup-fixup-error-handling-for-fleecing.patch
@@ -18,7 +18,7 @@ Signed-off-by: Fiona Ebner <f.ebner@proxmox.com>
1 file changed, 25 insertions(+), 13 deletions(-)
diff --git a/pve-backup.c b/pve-backup.c
-index 75da1dc051..167f0b5c3f 100644
+index 81697d9bf9..320c660589 100644
--- a/pve-backup.c
+++ b/pve-backup.c
@@ -357,22 +357,23 @@ static void coroutine_fn pvebackup_co_complete_stream(void *opaque)
diff --git a/debian/patches/pve/0047-PVE-backup-factor-out-setting-up-snapshot-access-for.patch b/debian/patches/pve/0047-PVE-backup-factor-out-setting-up-snapshot-access-for.patch
index 7cac5cb..ebd47dc 100644
--- a/debian/patches/pve/0047-PVE-backup-factor-out-setting-up-snapshot-access-for.patch
+++ b/debian/patches/pve/0047-PVE-backup-factor-out-setting-up-snapshot-access-for.patch
@@ -15,7 +15,7 @@ Signed-off-by: Fiona Ebner <f.ebner@proxmox.com>
1 file changed, 58 insertions(+), 37 deletions(-)
diff --git a/pve-backup.c b/pve-backup.c
-index 167f0b5c3f..f136d004c4 100644
+index 320c660589..d8d0c04b0f 100644
--- a/pve-backup.c
+++ b/pve-backup.c
@@ -525,6 +525,62 @@ static int coroutine_fn pvebackup_co_add_config(
diff --git a/debian/patches/pve/0048-PVE-backup-save-device-name-in-device-info-structure.patch b/debian/patches/pve/0048-PVE-backup-save-device-name-in-device-info-structure.patch
index a854b32..891e584 100644
--- a/debian/patches/pve/0048-PVE-backup-save-device-name-in-device-info-structure.patch
+++ b/debian/patches/pve/0048-PVE-backup-save-device-name-in-device-info-structure.patch
@@ -17,7 +17,7 @@ Signed-off-by: Fiona Ebner <f.ebner@proxmox.com>
1 file changed, 15 insertions(+), 14 deletions(-)
diff --git a/pve-backup.c b/pve-backup.c
-index f136d004c4..8ccb281c8c 100644
+index d8d0c04b0f..e2110ce0db 100644
--- a/pve-backup.c
+++ b/pve-backup.c
@@ -94,6 +94,7 @@ typedef struct PVEBackupDevInfo {
@@ -111,7 +111,7 @@ index f136d004c4..8ccb281c8c 100644
info->action = action;
info->size = di->size;
info->dirty = dirty;
-@@ -1034,10 +1035,7 @@ UuidInfo coroutine_fn *qmp_backup(
+@@ -1032,10 +1033,7 @@ UuidInfo coroutine_fn *qmp_backup(
goto err_mutex;
}
@@ -123,7 +123,7 @@ index f136d004c4..8ccb281c8c 100644
if (di->dev_id <= 0) {
error_set(errp, ERROR_CLASS_GENERIC_ERROR,
"register_stream failed");
-@@ -1148,6 +1146,9 @@ err:
+@@ -1146,6 +1144,9 @@ err:
bdrv_co_unref(di->target);
}
diff --git a/debian/patches/pve/0049-PVE-backup-include-device-name-in-error-when-setting.patch b/debian/patches/pve/0049-PVE-backup-include-device-name-in-error-when-setting.patch
index bf79355..807609a 100644
--- a/debian/patches/pve/0049-PVE-backup-include-device-name-in-error-when-setting.patch
+++ b/debian/patches/pve/0049-PVE-backup-include-device-name-in-error-when-setting.patch
@@ -10,7 +10,7 @@ Signed-off-by: Fiona Ebner <f.ebner@proxmox.com>
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/pve-backup.c b/pve-backup.c
-index 8ccb281c8c..255465676c 100644
+index e2110ce0db..32352fb5ec 100644
--- a/pve-backup.c
+++ b/pve-backup.c
@@ -626,7 +626,8 @@ static void create_backup_jobs_bh(void *opaque) {
--
2.39.5
_______________________________________________
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:[~2025-02-24 14:57 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-02-24 14:57 [pve-devel] [PATCH v2 qemu 1/2] replicated zfs migration: fix assertion failure with multiple disks Fiona Ebner
2025-02-24 14:57 ` Fiona Ebner [this message]
2025-02-24 16:40 ` [pve-devel] applied: " Thomas Lamprecht
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=20250224145705.140576-2-f.ebner@proxmox.com \
--to=f.ebner@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.
Service provided by Proxmox Server Solutions GmbH | Privacy | Legal