cpus: Constify some CPUState arguments
cover cpus: Constify some CPUState arguments
This is in preparation of making various CPUClass handlers take a const CPUState argument.
Philippe Mathieu-Daudé (7):
qemu/thread: Constify qemu_thread_get_affinity() 'thread' argument qemu/thread: Constify qemu_thread_is_self() argument
cpus: Constify qemu_cpu_is_self() argument
cpus: Constify cpu_get_address_space() 'cpu' argument
cpus: Constify cpu_is_stopped() argument
cpus: Constify cpu_work_list_empty() argument
accels: Constify AccelOpsClass::cpu_thread_is_idle() argument
include/hw/core/cpu.h | 6 +++--- include/qemu/thread.h | 6 +++--- include/system/accel-ops.h | 2 +- include/system/cpus.h | 2 +- accel/kvm/kvm-accel-ops.c | 2 +- bsd-user/main.c | 2 +- linux-user/main.c | 2 +- system/cpus.c | 6 +++--- system/physmem.c | 2 +- target/i386/whpx/whpx-accel-ops.c | 2 +- util/qemu-thread-posix.c | 6 +++--- util/qemu-thread-win32.c | 6 +++--- 12 files changed, 22 insertions(+), 22 deletions(-)
Signature · 1 line
2.47.1
PATCH 1/7 qemu/thread: Constify qemu_thread_get_affinity() 'thread' argument
QemuThread structure is not modified, only read.
--- include/qemu/thread.h | 4 ++-- util/qemu-thread-posix.c | 4 ++-- util/qemu-thread-win32.c | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-)
include/qemu/thread.h +2 -2
@@ -191,8 +191,8 @@ void qemu_thread_create(QemuThread *thread, const char *name, void *arg, int mode);int qemu_thread_set_affinity (QemuThread *thread,unsigned long *host_cpus,unsigned long nbits); -int qemu_thread_get_affinity (QemuThread *thread,unsigned long **host_cpus, -unsigned long *nbits); +int qemu_thread_get_affinity (const QemuThread *thread, +unsigned long **host_cpus,unsigned long *nbits);void *qemu_thread_join (QemuThread *thread);void qemu_thread_get_self (QemuThread *thread);bool qemu_thread_is_self (QemuThread *thread);
util/qemu-thread-posix.c +2 -2
@@ -617,8 +617,8 @@ int qemu_thread_set_affinity(QemuThread *thread, unsigned long *host_cpus,#endif } -int qemu_thread_get_affinity (QemuThread *thread,unsigned long **host_cpus, -unsigned long *nbits) +int qemu_thread_get_affinity (const QemuThread *thread, +unsigned long **host_cpus,unsigned long *nbits) {#if defined(CONFIG_PTHREAD_AFFINITY_NP )unsigned long tmpbits;
util/qemu-thread-win32.c +2 -2
@@ -513,8 +513,8 @@ int qemu_thread_set_affinity(QemuThread *thread, unsigned long *host_cpus,return -ENOSYS ; } -int qemu_thread_get_affinity (QemuThread *thread,unsigned long **host_cpus, -unsigned long *nbits) +int qemu_thread_get_affinity (const QemuThread *thread, +unsigned long **host_cpus,unsigned long *nbits) {return -ENOSYS ; }
Signature · 1 line
2.47.1
PATCH 2/7 qemu/thread: Constify qemu_thread_is_self() argument
In reply to Philippe Mathieu-DaudéQemuThread structure is not modified, only read.
--- include/qemu/thread.h | 2 +- util/qemu-thread-posix.c | 2 +- util/qemu-thread-win32.c | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-)
include/qemu/thread.h +1 -1
@@ -195,7 +195,7 @@ int qemu_thread_get_affinity(const QemuThread *thread, unsigned long **host_cpus, unsigned long *nbits);void *qemu_thread_join (QemuThread *thread);void qemu_thread_get_self (QemuThread *thread); -bool qemu_thread_is_self (QemuThread *thread); +bool qemu_thread_is_self (const QemuThread *thread); G_NORETURN void qemu_thread_exit(void *retval);void qemu_thread_naming (bool enable);
util/qemu-thread-posix.c +1 -1
@@ -664,7 +664,7 @@ void qemu_thread_get_self(QemuThread *thread) thread->thread =pthread_self (); } -bool qemu_thread_is_self (QemuThread *thread) +bool qemu_thread_is_self (const QemuThread *thread) {return pthread_equal (pthread_self (), thread->thread); }
util/qemu-thread-win32.c +1 -1
@@ -546,7 +546,7 @@ HANDLE qemu_thread_get_handle(QemuThread *thread)return handle; } -bool qemu_thread_is_self (QemuThread *thread) +bool qemu_thread_is_self (const QemuThread *thread) {return GetCurrentThreadId () == thread->tid; }
Signature · 1 line
2.47.1
PATCH 3/7 cpus: Constify qemu_cpu_is_self() argument
In reply to Philippe Mathieu-DaudéCPUState structure is not modified, make it const.
--- include/hw/core/cpu.h | 2 +- bsd-user/main.c | 2 +- linux-user/main.c | 2 +- system/cpus.c | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-)
include/hw/core/cpu.h +1 -1
@@ -838,7 +838,7 @@ static inline bool cpu_has_work(CPUState *cpu)* * Returns: %true if called from @cpu's thread, %false otherwise. */ -bool qemu_cpu_is_self (CPUState *cpu); +bool qemu_cpu_is_self (const CPUState *cpu);/** * qemu_cpu_kick:
bsd-user/main.c +1 -1
@@ -205,7 +205,7 @@ void stop_all_tasks(void)start_exclusive (); } -bool qemu_cpu_is_self (CPUState *cpu) +bool qemu_cpu_is_self (const CPUState *cpu) {return thread_cpu == cpu; }
linux-user/main.c +1 -1
@@ -181,7 +181,7 @@ void fork_end(pid_t pid) __threadCPUState *thread_cpu; -bool qemu_cpu_is_self (CPUState *cpu) +bool qemu_cpu_is_self (const CPUState *cpu) {return thread_cpu == cpu; }
system/cpus.c +1 -1
@@ -502,7 +502,7 @@ void qemu_cpu_kick_self(void)cpus_kick_thread (current_cpu); } -bool qemu_cpu_is_self (CPUState *cpu) +bool qemu_cpu_is_self (const CPUState *cpu) {return qemu_thread_is_self (cpu->thread); }
Signature · 1 line
2.47.1
PATCH 4/7 cpus: Constify cpu_get_address_space() 'cpu' argument
In reply to Philippe Mathieu-DaudéCPUState structure is not modified, make it const.
--- include/hw/core/cpu.h | 2 +- system/physmem.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-)
include/hw/core/cpu.h +1 -1
@@ -1155,7 +1155,7 @@ void cpu_watchpoint_remove_all(CPUState *cpu, int mask);* Return the requested address space of this CPU. @asidx * specifies which address space to read. */ -AddressSpace *cpu_get_address_space (CPUState *cpu,int asidx); +AddressSpace *cpu_get_address_space (const CPUState *cpu,int asidx); G_NORETURN void cpu_abort(CPUState *cpu, const char *fmt, ...) G_GNUC_PRINTF(2, 3);
system/physmem.c +1 -1
@@ -805,7 +805,7 @@ void cpu_address_space_destroy(CPUState *cpu, int asidx) } } -AddressSpace *cpu_get_address_space (CPUState *cpu,int asidx) +AddressSpace *cpu_get_address_space (const CPUState *cpu,int asidx) {/* Return the AddressSpace corresponding to the specified index */ return cpu->cpu_ases[asidx].as;
Signature · 1 line
2.47.1
PATCH 5/7 cpus: Constify cpu_is_stopped() argument
In reply to Philippe Mathieu-DaudéCPUState structure is not modified, make it const.
--- include/hw/core/cpu.h | 2 +- system/cpus.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-)
include/hw/core/cpu.h +1 -1
@@ -857,7 +857,7 @@ void qemu_cpu_kick(CPUState *cpu);* Returns: %true if run state is not running or if artificially stopped; * %false otherwise. */ -bool cpu_is_stopped (CPUState *cpu); +bool cpu_is_stopped (const CPUState *cpu);/** * do_run_on_cpu:
system/cpus.c +1 -1
@@ -73,7 +73,7 @@ static QemuMutex bql;*/ static const AccelOpsClass *cpus_accel; -bool cpu_is_stopped (CPUState *cpu) +bool cpu_is_stopped (const CPUState *cpu) {return cpu->stopped || !runstate_is_running (); }
Signature · 1 line
2.47.1
PATCH 6/7 cpus: Constify cpu_work_list_empty() argument
In reply to Philippe Mathieu-DaudéCPUState structure is not modified, make it const.
--- include/system/cpus.h | 2 +- system/cpus.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-)
include/system/cpus.h +1 -1
@@ -20,7 +20,7 @@ void dummy_start_vcpu_thread(CPUState *);#define VCPU_THREAD_NAME_SIZE 16void cpus_kick_thread (CPUState *cpu); -bool cpu_work_list_empty (CPUState *cpu); +bool cpu_work_list_empty (const CPUState *cpu);bool cpu_thread_is_idle (CPUState *cpu);bool all_cpu_threads_idle (void );bool cpu_can_run (CPUState *cpu);
system/cpus.c +1 -1
@@ -78,7 +78,7 @@ bool cpu_is_stopped(const CPUState *cpu)return cpu->stopped || !runstate_is_running (); } -bool cpu_work_list_empty (CPUState *cpu) +bool cpu_work_list_empty (const CPUState *cpu) {return QSIMPLEQ_EMPTY_ATOMIC (&cpu->work_list); }
Signature · 1 line
2.47.1
PATCH 7/7 accels: Constify AccelOpsClass::cpu_thread_is_idle() argument
In reply to Philippe Mathieu-DaudéIf a cpu_thread_is_idle() implementation accesses
@cpu fields, it shouldn't modify them. Make the
argument const in preparation.
--- include/system/accel-ops.h | 2 +- accel/kvm/kvm-accel-ops.c | 2 +- target/i386/whpx/whpx-accel-ops.c | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-)
include/system/accel-ops.h +1 -1
@@ -39,7 +39,7 @@ struct AccelOpsClass {void (*create_vcpu_thread)(CPUState *cpu);/* MANDATORY NON-NULL */ void (*kick_vcpu_thread)(CPUState *cpu); -bool (*cpu_thread_is_idle)(CPUState *cpu); +bool (*cpu_thread_is_idle)(const CPUState *cpu);void (*synchronize_post_reset)(CPUState *cpu);void (*synchronize_post_init)(CPUState *cpu);
accel/kvm/kvm-accel-ops.c +1 -1
@@ -72,7 +72,7 @@ static void kvm_start_vcpu_thread(CPUState *cpu) cpu, QEMU_THREAD_JOINABLE); } -static bool kvm_vcpu_thread_is_idle (CPUState *cpu) +static bool kvm_vcpu_thread_is_idle (const CPUState *cpu) {return !kvm_halt_in_kernel (); }
target/i386/whpx/whpx-accel-ops.c +1 -1
@@ -77,7 +77,7 @@ static void whpx_kick_vcpu_thread(CPUState *cpu) } } -static bool whpx_vcpu_thread_is_idle (CPUState *cpu) +static bool whpx_vcpu_thread_is_idle (const CPUState *cpu) {return !whpx_apic_in_platform (); }
Signature · 1 line
2.47.1
Quoted 11 lines · Philippe Mathieu-Daudé
This is in preparation of making various CPUClass handlers take a const CPUState argument.
Philippe Mathieu-Daudé (7):
qemu/thread: Constifyqemu_thread_get_affinity()'thread' argument qemu/thread: Constifyqemu_thread_is_self()argument
cpus: Constifyqemu_cpu_is_self()argument
cpus: Constifycpu_get_address_space()'cpu' argument
cpus: Constifycpu_is_stopped()argument
cpus: Constifycpu_work_list_empty()argument
accels: ConstifyAccelOpsClass::cpu_thread_is_idle()argument
ping?
Quoted 14 lines · Philippe Mathieu-Daudé
Quoted 11 lines · Philippe Mathieu-Daudé
This is in preparation of making various CPUClass handlers take a const CPUState argument.
Philippe Mathieu-Daudé (7):
qemu/thread: Constifyqemu_thread_get_affinity()'thread' argument qemu/thread: Constifyqemu_thread_is_self()argument
cpus: Constifyqemu_cpu_is_self()argument
cpus: Constifycpu_get_address_space()'cpu' argument
cpus: Constifycpu_is_stopped()argument
cpus: Constifycpu_work_list_empty()argument
accels: ConstifyAccelOpsClass::cpu_thread_is_idle()argument
Quoted 2 lines
ping?
Hi Philippe, I can't find this series in my mailbox and it's not on lore.kernel.org/patchew/lists.gnu.org either. Resend?
Quoted 16 lines · Manos Pitsidianakis
Quoted 14 lines · Philippe Mathieu-Daudé
Quoted 11 lines · Philippe Mathieu-Daudé
This is in preparation of making various CPUClass handlers take a const CPUState argument.
Philippe Mathieu-Daudé (7):
qemu/thread: Constifyqemu_thread_get_affinity()'thread' argument qemu/thread: Constifyqemu_thread_is_self()argument
cpus: Constifyqemu_cpu_is_self()argument
cpus: Constifycpu_get_address_space()'cpu' argument
cpus: Constifycpu_is_stopped()argument
cpus: Constifycpu_work_list_empty()argument
accels: ConstifyAccelOpsClass::cpu_thread_is_idle()argument
Quoted 6 lines
Quoted 2 lines
ping?
Hi Philippe, I can't find this series in my mailbox and it's not on lore.kernel.org/patchew/lists.gnu.org either. Resend?
Hi,
Looks like it landed on the kvm mailing list via Cc but was left out of qemu-devel, despite the seemingly correct To header:
https://lore.kernel.org/kvm/[email protected]/
Regards,
Yodel