Skip to contentSkip to conversation

system/runstate: Document qemu_add_vm_change_state_handler_prio* in hdr

PATCH-for-10.1 Applied Philippe Mathieu-Daudé 4 participants 5 messages Jul 15, 2025 – Jul 17, 2025

lore
Share & tools
lore
#0 lore raw

Generally APIs to the rest of QEMU should be documented in the headers. Comments on individual functions or internal details are fine to live in the C files. Make qemu_add_vm_change_state_handler_prio[_full]() docstrings consistent by moving them from source to header.

---
Based-on: <[email protected]>

---
 include/system/runstate.h | 30 ++++++++++++++++++++++++++++++
 system/runstate.c         | 30 ------------------------------
 2 files changed, 30 insertions(+), 30 deletions(-)
include/system/runstate.h +30 -0
index b6e8d6beab7..b8d1bc3d273 100644
@@ -26,9 +26,39 @@ typedef int VMChangeStateHandlerWithRet(void *opaque, bool running, RunState sta
  */
 VMChangeStateEntry *qemu_add_vm_change_state_handler(VMChangeStateHandler *cb,
                                                      void *opaque);
+/**
+ * qemu_add_vm_change_state_handler_prio:
+ * @cb: the callback to invoke
+ * @opaque: user data passed to the callback
+ * @priority: low priorities execute first when the vm runs and the reverse is
+ *            true when the vm stops
+ *
+ * Register a callback function that is invoked when the vm starts or stops
+ * running.
+ *
+ * Returns: an entry to be freed using qemu_del_vm_change_state_handler()
+ */
 VMChangeStateEntry *qemu_add_vm_change_state_handler_prio(
         VMChangeStateHandler *cb, void *opaque, int priority);
 VMChangeStateEntry *
+/**
+ * qemu_add_vm_change_state_handler_prio_full:
+ * @cb: the main callback to invoke
+ * @prepare_cb: a callback to invoke before the main callback
+ * @cb_ret: the main callback to invoke with return value
+ * @opaque: user data passed to the callbacks
+ * @priority: low priorities execute first when the vm runs and the reverse is
+ *            true when the vm stops
+ *
+ * Register a main callback function and an optional prepare callback function
+ * that are invoked when the vm starts or stops running. The main callback and
+ * the prepare callback are called in two separate phases: First all prepare
+ * callbacks are called and only then all main callbacks are called. As its
+ * name suggests, the prepare callback can be used to do some preparatory work
+ * before invoking the main callback.
+ *
+ * Returns: an entry to be freed using qemu_del_vm_change_state_handler()
+ */
 qemu_add_vm_change_state_handler_prio_full(VMChangeStateHandler *cb,
                                            VMChangeStateHandler *prepare_cb,
                                            VMChangeStateHandlerWithRet *cb_ret,
system/runstate.c +0 -30
index 38900c935a3..fa32aa47958 100644
@@ -306,18 +306,6 @@ struct VMChangeStateEntry {
 static QTAILQ_HEAD(, VMChangeStateEntry) vm_change_state_head =
     QTAILQ_HEAD_INITIALIZER(vm_change_state_head);
 
-/**
- * qemu_add_vm_change_state_handler_prio:
- * @cb: the callback to invoke
- * @opaque: user data passed to the callback
- * @priority: low priorities execute first when the vm runs and the reverse is
- *            true when the vm stops
- *
- * Register a callback function that is invoked when the vm starts or stops
- * running.
- *
- * Returns: an entry to be freed using qemu_del_vm_change_state_handler()
- */
 VMChangeStateEntry *qemu_add_vm_change_state_handler_prio(
         VMChangeStateHandler *cb, void *opaque, int priority)
 {
@@ -325,24 +313,6 @@ VMChangeStateEntry *qemu_add_vm_change_state_handler_prio(
                                                       opaque, priority);
 }
 
-/**
- * qemu_add_vm_change_state_handler_prio_full:
- * @cb: the main callback to invoke
- * @prepare_cb: a callback to invoke before the main callback
- * @cb_ret: the main callback to invoke with return value
- * @opaque: user data passed to the callbacks
- * @priority: low priorities execute first when the vm runs and the reverse is
- *            true when the vm stops
- *
- * Register a main callback function and an optional prepare callback function
- * that are invoked when the vm starts or stops running. The main callback and
- * the prepare callback are called in two separate phases: First all prepare
- * callbacks are called and only then all main callbacks are called. As its
- * name suggests, the prepare callback can be used to do some preparatory work
- * before invoking the main callback.
- *
- * Returns: an entry to be freed using qemu_del_vm_change_state_handler()
- */
 VMChangeStateEntry *
 qemu_add_vm_change_state_handler_prio_full(VMChangeStateHandler *cb,
                                            VMChangeStateHandler *prepare_cb,
Signature · 1 line
2.49.0
Reviewed-by
#1 lore raw
Quoted 5 lines · Philippe Mathieu-Daudé

Generally APIs to the rest of QEMU should be documented in the headers. Comments on individual functions or internal details are fine to live in the C files. Make qemu_add_vm_change_state_handler_prio[_full]() docstrings consistent by moving them from source to header.

Quoted 8 lines

---
Based-on: <[email protected]>

---
  include/system/runstate.h | 30 ++++++++++++++++++++++++++++++
  system/runstate.c         | 30 ------------------------------
  2 files changed, 30 insertions(+), 30 deletions(-)
#2 lore raw
In reply to Philippe Mathieu-Daudé
Quoted 5 lines · Philippe Mathieu-Daudé

Generally APIs to the rest of QEMU should be documented in the headers. Comments on individual functions or internal details are fine to live in the C files. Make qemu_add_vm_change_state_handler_prio[_full]() docstrings consistent by moving them from source to header.

Quoted 8 lines

---
Based-on: <[email protected]>

---
  include/system/runstate.h | 30 ++++++++++++++++++++++++++++++
  system/runstate.c         | 30 ------------------------------
  2 files changed, 30 insertions(+), 30 deletions(-)

Queued, thanks.

Reviewed-by
#3 lore raw
In reply to Philippe Mathieu-Daudé
Quoted 7 lines · Philippe Mathieu-Daudé

Generally APIs to the rest of QEMU should be documented in the headers. Comments on individual functions or internal details are fine to live in the C files. Make qemu_add_vm_change_state_handler_prio[_full]() docstrings consistent by moving them from source to header.

Quoted 7 lines

---
Based-on: <[email protected]>

---
  include/system/runstate.h | 30 ++++++++++++++++++++++++++++++
  system/runstate.c         | 30 ------------------------------
  2 files changed, 30 insertions(+), 30 deletions(-)
Reviewed-by
#4 lore raw
In reply to Philippe Mathieu-Daudé
Quoted 11 lines · Philippe Mathieu-Daudé

Date: Tue, 15 Jul 2025 19:19:20 +0200
From: Philippe Mathieu-Daudé <[email protected]>
Subject: [PATCH-for-10.1] system/runstate: Document
qemu_add_vm_change_state_handler_prio* in hdr
X-Mailer: git-send-email 2.49.0

Generally APIs to the rest of QEMU should be documented in the headers. Comments on individual functions or internal details are fine to live in the C files. Make qemu_add_vm_change_state_handler_prio[_full]() docstrings consistent by moving them from source to header.

Quoted 8 lines

---
Based-on: <[email protected]>

---
 include/system/runstate.h | 30 ++++++++++++++++++++++++++++++
 system/runstate.c         | 30 ------------------------------
 2 files changed, 30 insertions(+), 30 deletions(-)