Patch Detail
get:
Show a patch.
patch:
Update a patch.
put:
Update a patch.
GET /api/patches/2215599/?format=api
{ "id": 2215599, "url": "http://patchwork.ozlabs.org/api/patches/2215599/?format=api", "web_url": "http://patchwork.ozlabs.org/project/qemu-devel/patch/20260324194333.30004-18-farosas@suse.de/", "project": { "id": 14, "url": "http://patchwork.ozlabs.org/api/projects/14/?format=api", "name": "QEMU Development", "link_name": "qemu-devel", "list_id": "qemu-devel.nongnu.org", "list_email": "qemu-devel@nongnu.org", "web_url": "", "scm_url": "", "webscm_url": "", "list_archive_url": "", "list_archive_url_format": "", "commit_url_format": "" }, "msgid": "<20260324194333.30004-18-farosas@suse.de>", "list_archive_url": null, "date": "2026-03-24T19:43:32", "name": "[RFC,v1,17/17] vmstate: Reduce indentation levels", "commit_ref": null, "pull_url": null, "state": "new", "archived": false, "hash": "7a6914a78820dc626a6bc907c2fed351dab33825", "submitter": { "id": 85343, "url": "http://patchwork.ozlabs.org/api/people/85343/?format=api", "name": "Fabiano Rosas", "email": "farosas@suse.de" }, "delegate": null, "mbox": "http://patchwork.ozlabs.org/project/qemu-devel/patch/20260324194333.30004-18-farosas@suse.de/mbox/", "series": [ { "id": 497339, "url": "http://patchwork.ozlabs.org/api/series/497339/?format=api", "web_url": "http://patchwork.ozlabs.org/project/qemu-devel/list/?series=497339", "date": "2026-03-24T19:43:16", "name": "migration: vmstate_save|load changes for peterx", "version": 1, "mbox": "http://patchwork.ozlabs.org/series/497339/mbox/" } ], "comments": "http://patchwork.ozlabs.org/api/patches/2215599/comments/", "check": "pending", "checks": "http://patchwork.ozlabs.org/api/patches/2215599/checks/", "tags": {}, "related": [], "headers": { "Return-Path": "<qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org>", "X-Original-To": "incoming@patchwork.ozlabs.org", "Delivered-To": "patchwork-incoming@legolas.ozlabs.org", "Authentication-Results": [ "legolas.ozlabs.org;\n\tdkim=pass (1024-bit key;\n unprotected) header.d=suse.de header.i=@suse.de header.a=rsa-sha256\n header.s=susede2_rsa header.b=VXdP7x+u;\n\tdkim=pass header.d=suse.de header.i=@suse.de header.a=ed25519-sha256\n header.s=susede2_ed25519 header.b=cskHf+uk;\n\tdkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de\n header.a=rsa-sha256 header.s=susede2_rsa header.b=VXdP7x+u;\n\tdkim=neutral header.d=suse.de header.i=@suse.de header.a=ed25519-sha256\n header.s=susede2_ed25519 header.b=cskHf+uk;\n\tdkim-atps=neutral", "legolas.ozlabs.org;\n spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org\n (client-ip=209.51.188.17; helo=lists.gnu.org;\n envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org;\n receiver=patchwork.ozlabs.org)", "smtp-out2.suse.de;\n\tnone" ], "Received": [ "from lists.gnu.org (lists.gnu.org [209.51.188.17])\n\t(using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits))\n\t(No client certificate requested)\n\tby legolas.ozlabs.org (Postfix) with ESMTPS id 4fgL9m30GWz1y1G\n\tfor <incoming@patchwork.ozlabs.org>; Wed, 25 Mar 2026 06:45:32 +1100 (AEDT)", "from localhost ([::1] helo=lists1p.gnu.org)\n\tby lists.gnu.org with esmtp (Exim 4.90_1)\n\t(envelope-from <qemu-devel-bounces@nongnu.org>)\n\tid 1w57g0-0003YK-AH; Tue, 24 Mar 2026 15:44:32 -0400", "from eggs.gnu.org ([2001:470:142:3::10])\n by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)\n (Exim 4.90_1) (envelope-from <farosas@suse.de>) id 1w57fz-0003WF-0h\n for qemu-devel@nongnu.org; Tue, 24 Mar 2026 15:44:31 -0400", "from smtp-out2.suse.de ([195.135.223.131])\n by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128)\n (Exim 4.90_1) (envelope-from <farosas@suse.de>) id 1w57fx-0008IL-4B\n for qemu-devel@nongnu.org; Tue, 24 Mar 2026 15:44:30 -0400", "from imap1.dmz-prg2.suse.org (unknown [10.150.64.97])\n (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)\n key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest\n SHA256)\n (No client certificate requested)\n by smtp-out2.suse.de (Postfix) with ESMTPS id 37EC85BE1C;\n Tue, 24 Mar 2026 19:44:03 +0000 (UTC)", "from imap1.dmz-prg2.suse.org (localhost [127.0.0.1])\n (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)\n key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest\n SHA256)\n (No client certificate requested)\n by imap1.dmz-prg2.suse.org (Postfix) with ESMTPS id 0F97743FE4;\n Tue, 24 Mar 2026 19:44:01 +0000 (UTC)", "from dovecot-director2.suse.de ([2a07:de40:b281:106:10:150:64:167])\n by imap1.dmz-prg2.suse.org with ESMTPSA id eHwnNIHpwmlkMQAAD6G6ig\n (envelope-from <farosas@suse.de>); Tue, 24 Mar 2026 19:44:01 +0000" ], "DKIM-Signature": [ "v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de;\n s=susede2_rsa;\n t=1774381443;\n h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc:\n mime-version:mime-version:\n content-transfer-encoding:content-transfer-encoding:\n in-reply-to:in-reply-to:references:references;\n bh=Y1stviN/raIeGwfKRJGzfc+zY9+icZReG+c5s58fsdo=;\n b=VXdP7x+urG6oRbRSv+cO2dKT8gYkMbhvwFXO3lrBM27R+gmNnqpkn1snxKyJsCdAaH608I\n FYhYfGCvnNtuBLUpvebB28BnjsXKdeLJHR05qyniDVDzfEdKwIibeDa56nCCJtYpglrZeY\n bapb9I9SoDXf16W5x3xqWHtF2iUqoGc=", "v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de;\n s=susede2_ed25519; t=1774381443;\n h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc:\n mime-version:mime-version:\n content-transfer-encoding:content-transfer-encoding:\n in-reply-to:in-reply-to:references:references;\n bh=Y1stviN/raIeGwfKRJGzfc+zY9+icZReG+c5s58fsdo=;\n b=cskHf+ukmCAfaP7umTs3ZqsGRjG8mCalhhU0tCCuBqWvQuKYXJUvspNk4yLU4KcllUjfm8\n oMVl4BiwHtdBNrBg==", "v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de;\n s=susede2_rsa;\n t=1774381443;\n h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc:\n mime-version:mime-version:\n content-transfer-encoding:content-transfer-encoding:\n in-reply-to:in-reply-to:references:references;\n bh=Y1stviN/raIeGwfKRJGzfc+zY9+icZReG+c5s58fsdo=;\n b=VXdP7x+urG6oRbRSv+cO2dKT8gYkMbhvwFXO3lrBM27R+gmNnqpkn1snxKyJsCdAaH608I\n FYhYfGCvnNtuBLUpvebB28BnjsXKdeLJHR05qyniDVDzfEdKwIibeDa56nCCJtYpglrZeY\n bapb9I9SoDXf16W5x3xqWHtF2iUqoGc=", "v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de;\n s=susede2_ed25519; t=1774381443;\n h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc:\n mime-version:mime-version:\n content-transfer-encoding:content-transfer-encoding:\n in-reply-to:in-reply-to:references:references;\n bh=Y1stviN/raIeGwfKRJGzfc+zY9+icZReG+c5s58fsdo=;\n b=cskHf+ukmCAfaP7umTs3ZqsGRjG8mCalhhU0tCCuBqWvQuKYXJUvspNk4yLU4KcllUjfm8\n oMVl4BiwHtdBNrBg==" ], "From": "Fabiano Rosas <farosas@suse.de>", "To": "qemu-devel@nongnu.org", "Cc": "Peter Xu <peterx@redhat.com>,\n Alexander Mikhalitsyn <alexander@mihalicyn.com>,\n Juraj Marcin <jmarcin@redhat.com>", "Subject": "[RFC PATCH v1 17/17] vmstate: Reduce indentation levels", "Date": "Tue, 24 Mar 2026 16:43:32 -0300", "Message-ID": "<20260324194333.30004-18-farosas@suse.de>", "X-Mailer": "git-send-email 2.51.0", "In-Reply-To": "<20260324194333.30004-1-farosas@suse.de>", "References": "<20260324194333.30004-1-farosas@suse.de>", "MIME-Version": "1.0", "Content-Transfer-Encoding": "8bit", "X-Spam-Score": "-2.80", "X-Spamd-Result": "default: False [-2.80 / 50.00]; BAYES_HAM(-3.00)[100.00%];\n MID_CONTAINS_FROM(1.00)[]; NEURAL_HAM_LONG(-1.00)[-1.000];\n R_MISSING_CHARSET(0.50)[]; NEURAL_HAM_SHORT(-0.20)[-1.000];\n MIME_GOOD(-0.10)[text/plain];\n DKIM_SIGNED(0.00)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519];\n MIME_TRACE(0.00)[0:+]; TO_MATCH_ENVRCPT_ALL(0.00)[];\n ARC_NA(0.00)[]; FUZZY_RATELIMITED(0.00)[rspamd.com];\n RCPT_COUNT_THREE(0.00)[4]; TO_DN_SOME(0.00)[];\n FROM_EQ_ENVFROM(0.00)[]; FROM_HAS_DN(0.00)[];\n RCVD_TLS_ALL(0.00)[]; RCVD_COUNT_TWO(0.00)[2];\n R_RATELIMIT(0.00)[to_ip_from(RLuo5zndapfjusa9yqdunguuf8)];\n RCVD_VIA_SMTP_AUTH(0.00)[];\n DBL_BLOCKED_OPENRESOLVER(0.00)[suse.de:mid,suse.de:email]", "Received-SPF": "pass client-ip=195.135.223.131; envelope-from=farosas@suse.de;\n helo=smtp-out2.suse.de", "X-Spam_score_int": "-43", "X-Spam_score": "-4.4", "X-Spam_bar": "----", "X-Spam_report": "(-4.4 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1,\n DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1,\n RCVD_IN_DNSWL_MED=-2.3, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=0.001,\n RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, SPF_HELO_NONE=0.001,\n SPF_PASS=-0.001 autolearn=ham autolearn_force=no", "X-Spam_action": "no action", "X-BeenThere": "qemu-devel@nongnu.org", "X-Mailman-Version": "2.1.29", "Precedence": "list", "List-Id": "qemu development <qemu-devel.nongnu.org>", "List-Unsubscribe": "<https://lists.nongnu.org/mailman/options/qemu-devel>,\n <mailto:qemu-devel-request@nongnu.org?subject=unsubscribe>", "List-Archive": "<https://lists.nongnu.org/archive/html/qemu-devel>", "List-Post": "<mailto:qemu-devel@nongnu.org>", "List-Help": "<mailto:qemu-devel-request@nongnu.org?subject=help>", "List-Subscribe": "<https://lists.nongnu.org/mailman/listinfo/qemu-devel>,\n <mailto:qemu-devel-request@nongnu.org?subject=subscribe>", "Errors-To": "qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org", "Sender": "qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org" }, "content": "Simply move the code out of the else branch.\n\nSigned-off-by: Fabiano Rosas <farosas@suse.de>\n---\n migration/vmstate.c | 193 ++++++++++++++++++++++----------------------\n 1 file changed, 96 insertions(+), 97 deletions(-)", "diff": "diff --git a/migration/vmstate.c b/migration/vmstate.c\nindex 054e642ec9..22f8758960 100644\n--- a/migration/vmstate.c\n+++ b/migration/vmstate.c\n@@ -306,46 +306,46 @@ bool vmstate_load_vmsd(QEMUFile *f, const VMStateDescription *vmsd,\n if (!exists) {\n field++;\n continue;\n- } else {\n- n_elems = vmstate_n_elems(opaque, field);\n- size = vmstate_size(opaque, field);\n+ }\n \n- head = vmstate_first(opaque, field, size, n_elems,\n- !(field->flags & VMS_ARRAY_OF_POINTER));\n+ n_elems = vmstate_n_elems(opaque, field);\n+ size = vmstate_size(opaque, field);\n \n- for (i = 0; i < n_elems; i++) {\n- /* If we will process the load of field? */\n- bool load_field = true;\n- void *curr_elem;\n+ head = vmstate_first(opaque, field, size, n_elems,\n+ !(field->flags & VMS_ARRAY_OF_POINTER));\n \n- if (field->flags & VMS_ARRAY_OF_POINTER) {\n- /* Peek a possible pointer marker instead of VMSD first */\n- ok = vmstate_ptr_marker_load(f, &load_field);\n- }\n+ for (i = 0; i < n_elems; i++) {\n+ /* If we will process the load of field? */\n+ bool load_field = true;\n+ void *curr_elem;\n \n- curr_elem = vmstate_next(head, field, size, i,\n- load_field && ok);\n+ if (field->flags & VMS_ARRAY_OF_POINTER) {\n+ /* Peek a possible pointer marker instead of VMSD first */\n+ ok = vmstate_ptr_marker_load(f, &load_field);\n+ }\n \n- if (load_field) {\n- ok = vmstate_load_field(f, curr_elem, size, field, errp);\n- }\n+ curr_elem = vmstate_next(head, field, size, i, load_field && ok);\n \n- if (ok) {\n- int ret = qemu_file_get_error(f);\n- if (ret < 0) {\n- error_setg(errp,\n- \"Failed to load %s state: stream error: %d\",\n- vmsd->name, ret);\n- trace_vmstate_load_field_error(field->name, ret);\n- return false;\n- }\n- } else {\n- qemu_file_set_error(f, -EINVAL);\n- trace_vmstate_load_field_error(field->name, -EINVAL);\n+ if (load_field) {\n+ ok = vmstate_load_field(f, curr_elem, size, field, errp);\n+ }\n+\n+ if (ok) {\n+ int ret = qemu_file_get_error(f);\n+ if (ret < 0) {\n+ error_setg(errp,\n+ \"Failed to load %s state: stream error: %d\",\n+ vmsd->name, ret);\n+ trace_vmstate_load_field_error(field->name, ret);\n return false;\n }\n+ } else {\n+ qemu_file_set_error(f, -EINVAL);\n+ trace_vmstate_load_field_error(field->name, -EINVAL);\n+ return false;\n }\n }\n+\n field++;\n }\n assert(field->flags == VMS_END);\n@@ -663,93 +663,92 @@ static bool vmstate_save_vmsd_v(QEMUFile *f, const VMStateDescription *vmsd,\n if (!exists) {\n field++;\n continue;\n- } else {\n- n_elems = vmstate_n_elems(opaque, field);\n- size = vmstate_size(opaque, field);\n+ }\n \n- trace_vmstate_save_state_loop(vmsd->name, field->name, n_elems);\n- head = vmstate_first(opaque, field, size, n_elems, false);\n+ n_elems = vmstate_n_elems(opaque, field);\n+ size = vmstate_size(opaque, field);\n \n- for (i = 0; i < n_elems; i++) {\n- bool save_field = true;\n- void *curr_elem = vmstate_next(head, field, size, i, false);\n- int max_elems = n_elems - i;\n+ trace_vmstate_save_state_loop(vmsd->name, field->name, n_elems);\n+ head = vmstate_first(opaque, field, size, n_elems, false);\n \n- if (field->flags & VMS_ARRAY_OF_POINTER) {\n- bool use_marker_field, is_null, use_dynamic_array;\n+ for (i = 0; i < n_elems; i++) {\n+ bool save_field = true;\n+ void *curr_elem = vmstate_next(head, field, size, i, false);\n+ int max_elems = n_elems - i;\n \n- is_null = !curr_elem;\n+ if (field->flags & VMS_ARRAY_OF_POINTER) {\n+ bool use_marker_field, is_null, use_dynamic_array;\n \n+ is_null = !curr_elem;\n+\n+ /*\n+ * When this is enabled, it means we will always push a ptr\n+ * marker first for each element saying if it's populated.\n+ */\n+ use_dynamic_array =\n+ field->flags & VMS_ARRAY_OF_POINTER &&\n+ field->flags & VMS_ALLOC;\n+\n+ use_marker_field = use_dynamic_array || is_null;\n+\n+ if (vmdesc && vmsd_can_compress(field)) {\n /*\n- * When this is enabled, it means we will always push a ptr\n- * marker first for each element saying if it's populated.\n+ * This logic only matters when dumping VM\n+ * Desc, and only when the VMSD field can be\n+ * compressed.\n+ *\n+ * Due to the fake nullptr handling above, if\n+ * there's mixed null/non-null data, it\n+ * doesn't make sense to emit a compressed\n+ * array representation spanning the entire\n+ * array because the field types will be\n+ * different (e.g. struct vs. nullptr). Search\n+ * ahead for the next null/non-null element\n+ * and start a new compressed array if found.\n */\n- use_dynamic_array =\n- field->flags & VMS_ARRAY_OF_POINTER &&\n- field->flags & VMS_ALLOC;\n-\n- use_marker_field = use_dynamic_array || is_null;\n-\n- if (vmdesc && vmsd_can_compress(field)) {\n- /*\n- * This logic only matters when dumping VM\n- * Desc, and only when the VMSD field can be\n- * compressed.\n- *\n- * Due to the fake nullptr handling above, if\n- * there's mixed null/non-null data, it\n- * doesn't make sense to emit a compressed\n- * array representation spanning the entire\n- * array because the field types will be\n- * different (e.g. struct vs. nullptr). Search\n- * ahead for the next null/non-null element\n- * and start a new compressed array if found.\n- */\n- if (is_null != is_null_prev) {\n- is_null_prev = is_null;\n- use_vmdesc = true;\n-\n- for (int j = i + 1; j < n_elems; j++) {\n- void *elem = vmstate_next(head, field, size, j,\n- false);\n- bool elem_is_null = !elem;\n-\n- if (is_null != elem_is_null) {\n- max_elems = j - i;\n- break;\n- }\n- }\n- }\n- }\n-\n- if (use_dynamic_array) {\n+ if (is_null != is_null_prev) {\n+ is_null_prev = is_null;\n use_vmdesc = true;\n- }\n \n- if (use_marker_field) {\n- ok = vmstate_ptr_marker_save(f, curr_elem, vmsd, field,\n- use_vmdesc ? vmdesc : NULL,\n- i, max_elems, errp);\n- if (!ok) {\n- goto out;\n+ for (int j = i + 1; j < n_elems; j++) {\n+ void *elem = vmstate_next(head, field, size, j,\n+ false);\n+ bool elem_is_null = !elem;\n+\n+ if (is_null != elem_is_null) {\n+ max_elems = j - i;\n+ break;\n+ }\n }\n-\n- save_field = !!curr_elem;\n }\n }\n \n- if (save_field) {\n- ok = vmstate_save_field_with_vmdesc(\n- f, curr_elem, size, vmsd, field,\n- use_vmdesc ? vmdesc : NULL, i, max_elems, errp);\n+ if (use_dynamic_array) {\n+ use_vmdesc = true;\n+ }\n \n+ if (use_marker_field) {\n+ ok = vmstate_ptr_marker_save(f, curr_elem, vmsd, field,\n+ use_vmdesc ? vmdesc : NULL,\n+ i, max_elems, errp);\n if (!ok) {\n goto out;\n }\n+\n+ save_field = !!curr_elem;\n }\n+ }\n \n- use_vmdesc = false;\n+ if (save_field) {\n+ ok = vmstate_save_field_with_vmdesc(f, curr_elem, size, vmsd,\n+ field,\n+ use_vmdesc ? vmdesc : NULL,\n+ i, max_elems, errp);\n+ if (!ok) {\n+ goto out;\n+ }\n }\n+ use_vmdesc = false;\n }\n field++;\n }\n", "prefixes": [ "RFC", "v1", "17/17" ] }