Trim dependencies of qemu-ga, vscclient, tests
cover Trim dependencies of qemu-ga, vscclient, tests
qemu-ga and vscclient have a very long list of dependencies, but this is mostly because of tools-obj-y and because of qemu-tool.c's own dependencies.
These are complex to disentangle, and became worse with recent additions (especially fdsets). Luckily, some dependencies (for example on qemu-timer.c, patches 8-10) can be removed from qemu-tool.c. When not possible or overly complex, stuff can be moved out of qemu-tool.c and into the files that actually require the stubbed-out functions, using weak references.
I would like to do more of these, but because of the currently-broken state of Win32 and slightly different semantics of weak references between ELF and Win32, this does just the minimum necessary.
Paolo
Paolo Bonzini (11):
janitor: move iovector functions out of cutils.c
build: move cutils.o and qemu-timer-common.o to oslib-obj-y
compiler: use weak aliases to provide default definitions
sockets: use weak aliases instead of qemu-tool.c
fdsets: use weak aliases instead of qemu-tool.c/qemu-user.c
iohandler: add weak alias in qemu-sockets.c, for qemu-ga
win32: add weak version of qemu_fd_register
qemu-timer: make initialization functions idempotent
main-loop: unify qemu_init_main_loop between QEMU and tools
qemu-tool: do not depend on qemu-timer.c
build: do not include main loop where it is not actually used
Makefile | 7 ++-- Makefile.objs | 13 ++++--- arch_init.h | 2 +- compiler.h | 11 +++--- cutils.c | 108 --------------------------------------------------------- iov.c | 103 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ main-loop.c | 5 ++- main-loop.h | 10 ------ osdep.c | 30 ++++++++++++++++ oslib-win32.c | 5 +++ qemu-common.h | 1 - qemu-sockets.c | 18 ++++++++++ qemu-timer.c | 12 +++++-- qemu-tool.c | 35 +------------------ qemu-user.c | 20 ----------- qmp.c | 3 +- tests/Makefile | 4 +-- vl.c | 5 ---
18 file modificati, 188 inserzioni(+), 204 rimozioni(-)
Signature · 1 line
1.7.12.1
PATCH 1/11 janitor: move iovector functions out of cutils.c
This removes the dependency of cutils.c on iov.c, and lets us remove iov.o from several builds.
--- Makefile | 2 +- Makefile.objs | 4 +-- cutils.c | 103 --------------------------------------------------------- iov.c | 103 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++ tests/Makefile | 2 +-
5 file modificati, 107 inserzioni(+), 107 rimozioni(-)
Makefile +1 -1
@@ -172,7 +172,7 @@ qemu-img.o: qemu-img-cmds.h tools-obj-y = $(oslib-obj-y) $(trace-obj-y) qemu-tool.o qemu-timer.o \ qemu-timer-common.o main-loop.o notify.o \ - iohandler.o cutils.o iov.o async.o error.o + iohandler.o cutils.o async.o error.o tools-obj-$(CONFIG_POSIX) += compatfd.o qemu-img$(EXESUF): qemu-img.o $(tools-obj-y) $(block-obj-y)
Makefile.objs +2 -2
@@ -92,7 +92,7 @@ common-obj-y += ui/ common-obj-y += bt-host.o bt-vhci.o common-obj-y += dma-helpers.o -common-obj-y += iov.o acl.o +common-obj-y += acl.o common-obj-$(CONFIG_POSIX) += compatfd.o common-obj-y += event_notifier.o common-obj-y += qemu-timer.o qemu-timer-common.o
@@ -113,7 +113,7 @@ endif user-obj-y = user-obj-y += envlist.o path.o user-obj-y += tcg-runtime.o host-utils.o -user-obj-y += cutils.o iov.o cache-utils.o +user-obj-y += cutils.o cache-utils.o user-obj-y += module.o user-obj-y += qemu-user.o user-obj-y += $(trace-obj-y)
cutils.c +0 -103
109 lines not on this page · raw message
iov.c +103 -0
106 lines not on this page · raw message
tests/Makefile +1 -1
@@ -48,7 +48,7 @@ tests/check-qdict$(EXESUF): tests/check-qdict.o qdict.o qfloat.o qint.o qstring. tests/check-qlist$(EXESUF): tests/check-qlist.o qlist.o qint.o tests/check-qfloat$(EXESUF): tests/check-qfloat.o qfloat.o tests/check-qjson$(EXESUF): tests/check-qjson.o $(qobject-obj-y) $(tools-obj-y) -tests/test-coroutine$(EXESUF): tests/test-coroutine.o $(coroutine-obj-y) $(tools-obj-y) +tests/test-coroutine$(EXESUF): tests/test-coroutine.o $(coroutine-obj-y) $(tools-obj-y) iov.o tests/test-iov$(EXESUF): tests/test-iov.o iov.o tests/test-qapi-types.c tests/test-qapi-types.h :\
Signature · 1 line
1.7.12.1
PATCH 2/11 build: move cutils.o and qemu-timer-common.o to oslib-obj-y
In reply to Paolo Bonzini--- Makefile | 3 +-- Makefile.objs | 6 +++---
2 file modificati, 4 inserzioni(+), 5 rimozioni(-)
Makefile +1 -2
@@ -171,8 +171,7 @@ endif qemu-img.o: qemu-img-cmds.h tools-obj-y = $(oslib-obj-y) $(trace-obj-y) qemu-tool.o qemu-timer.o \ - qemu-timer-common.o main-loop.o notify.o \ - iohandler.o cutils.o async.o error.o + main-loop.o notify.o iohandler.o async.o error.o tools-obj-$(CONFIG_POSIX) += compatfd.o qemu-img$(EXESUF): qemu-img.o $(tools-obj-y) $(block-obj-y)
Makefile.objs +3 -3
@@ -19,7 +19,7 @@ universal-obj-y += $(qom-obj-y) ####################################################################### # oslib-obj-y is code depending on the OS (win32 vs posix) -oslib-obj-y = osdep.o +oslib-obj-y = osdep.o cutils.o qemu-timer-common.o oslib-obj-$(CONFIG_WIN32) += oslib-win32.o qemu-thread-win32.o oslib-obj-$(CONFIG_POSIX) += oslib-posix.o qemu-thread-posix.o
@@ -41,7 +41,7 @@ coroutine-obj-$(CONFIG_WIN32) += coroutine-win32.o ####################################################################### # block-obj-y is code used by both qemu system emulation and qemu-img -block-obj-y = cutils.o iov.o cache-utils.o qemu-option.o module.o async.o +block-obj-y = iov.o cache-utils.o qemu-option.o module.o async.o block-obj-y += nbd.o block.o blockjob.o aio.o aes.o qemu-config.o block-obj-y += qemu-progress.o qemu-sockets.o uri.o notify.o block-obj-y += $(coroutine-obj-y) $(qobject-obj-y) $(version-obj-y)
@@ -113,7 +113,7 @@ endif user-obj-y = user-obj-y += envlist.o path.o user-obj-y += tcg-runtime.o host-utils.o -user-obj-y += cutils.o cache-utils.o +user-obj-y += cache-utils.o user-obj-y += module.o user-obj-y += qemu-user.o user-obj-y += $(trace-obj-y)
Signature · 1 line
1.7.12.1
PATCH 3/11 compiler: use weak aliases to provide default definitions
In reply to Paolo BonziniThis is simpler and more portable.
--- arch_init.h | 2 +- compiler.h | 11 ++++------- qmp.c | 3 ++-
3 file modificati, 7 inserzioni(+), 9 rimozioni(-)
arch_init.h +1 -1
@@ -34,6 +34,6 @@ int tcg_available(void);int kvm_available (void );int xen_available (void ); -CpuDefinitionInfoList GCC_WEAK_DECL *arch_query_cpu_definitions(Error **errp); +CpuDefinitionInfoList *arch_query_cpu_definitions (Error **errp);#endif
compiler.h +4 -7
@@ -50,16 +50,13 @@# define __printf__ __gnu_printf__# endif # endif -#if defined(_WIN32) -#define GCC_WEAK __attribute__((weak)) -#define GCC_WEAK_DECL GCC_WEAK -#else -#define GCC_WEAK __attribute__((weak)) -#define GCC_WEAK_DECL -#endif +# define QEMU_WEAK_ALIAS (newname, oldname) \ + typeof(oldname) newname __attribute__((weak, alias (#oldname)))#else #define GCC_ATTR /**/ #define GCC_FMT_ATTR (n, m) +#define QEMU_WEAK_ALIAS (newname, oldname) \ + _Pragma("weak " #newname "=" #oldname)#endif #endif /* COMPILER_H */
qmp.c +2 -1
@@ -471,11 +471,12 @@ DevicePropertyInfoList *qmp_device_list_properties(const char *typename,return prop_list; } -CpuDefinitionInfoList GCC_WEAK *arch_query_cpu_definitions(Error **errp) +static CpuDefinitionInfoList *default_arch_query_cpu_definitions (Error **errp) {error_set (errp,QERR_NOT_SUPPORTED );return NULL ; } +QEMU_WEAK_ALIAS (arch_query_cpu_definitions, default_arch_query_cpu_definitions);CpuDefinitionInfoList *qmp_query_cpu_definitions (Error **errp) {
Signature · 1 line
1.7.12.1
PATCH 4/11 sockets: use weak aliases instead of qemu-tool.c
In reply to Paolo Bonziniqemu-tool.c has its own (largeish) set of dependencies. Weak aliases can be placed directly where people use them, and do not contribute to increasing the dependencies of generic utility files.
--- qemu-sockets.c | 7 +++++++ qemu-tool.c | 6 ------
2 file modificati, 7 inserzioni(+), 6 rimozioni(-)
qemu-sockets.c +7 -0
@@ -967,3 +967,10 @@ int socket_init(void)#endif return 0 ; } + +static int default_monitor_get_fd (Monitor *mon,const char *name,Error **errp) +{ +error_setg (errp,"only QEMU supports file descriptor passing" ); +return -1 ; +} +QEMU_WEAK_ALIAS (monitor_get_fd, default_monitor_get_fd);
qemu-tool.c +0 -6
@@ -38,12 +38,6 @@ const char *qemu_get_vm_name(void)Monitor *cur_mon; -int monitor_get_fd (Monitor *mon,const char *name,Error **errp) -{ -error_setg (errp,"only QEMU supports file descriptor passing" ); -return -1 ; -} -void vm_stop (RunState state) {abort ();
Signature · 1 line
1.7.12.1
PATCH 5/11 fdsets: use weak aliases instead of qemu-tool.c/qemu-user.c
In reply to Paolo Bonzini--- cutils.c | 5 ----- osdep.c | 30 ++++++++++++++++++++++++++++++ qemu-common.h | 1 - qemu-tool.c | 20 -------------------- qemu-user.c | 20 --------------------
5 file modificati, 30 inserzioni(+), 46 rimozioni(-)
cutils.c +0 -5
@@ -280,11 +280,6 @@ int qemu_parse_fd(const char *param)return fd; } -int qemu_parse_fdset (const char *param) -{ -return qemu_parse_fd (param); -} -/* round down to the nearest power of 2*/ int64_t pow2floor (int64_t value) {
osdep.c +30 -0
@@ -144,6 +144,11 @@ fail: errno = serrno; return -1; } + +static int qemu_parse_fdset (const char *param) +{ +return qemu_parse_fd (param); +}#endif /*
@@ -404,3 +409,28 @@ bool fips_get_state(void) {return fips_enabled; } + + +static int default_fdset_get_fd (int64_t fdset_id,int flags) +{ +return -1 ; +} +QEMU_WEAK_ALIAS (monitor_fdset_get_fd, default_fdset_get_fd); + +static int default_fdset_dup_fd_add (int64_t fdset_id,int dup_fd) +{ +return -1 ; +} +QEMU_WEAK_ALIAS (monitor_fdset_dup_fd_add, default_fdset_dup_fd_add); + +static int default_fdset_dup_fd_remove (int dup_fd) +{ +return -1 ; +} +QEMU_WEAK_ALIAS (monitor_fdset_dup_fd_remove, default_fdset_dup_fd_remove); + +static int default_fdset_dup_fd_find (int dup_fd) +{ +return -1 ; +} +QEMU_WEAK_ALIAS (monitor_fdset_dup_fd_find, default_fdset_dup_fd_find);
qemu-common.h +0 -1
@@ -167,7 +167,6 @@ int qemu_fls(int i);int qemu_fdatasync (int fd);int fcntl_setfl (int fd,int flag);int qemu_parse_fd (const char *param); -int qemu_parse_fdset (const char *param);/* * strtosz() suffixes used to specify the default treatment of an
qemu-tool.c +0 -20
@@ -68,26 +68,6 @@ void monitor_protocol_event(MonitorEvent event, QObject *data) { } -int monitor_fdset_get_fd (int64_t fdset_id,int flags) -{ -return -1 ; -} - -int monitor_fdset_dup_fd_add (int64_t fdset_id,int dup_fd) -{ -return -1 ; -} - -int monitor_fdset_dup_fd_remove (int dup_fd) -{ -return -1 ; -} - -int monitor_fdset_dup_fd_find (int dup_fd) -{ -return -1 ; -} -int64_t cpu_get_clock (void ) {return qemu_get_clock_ns (rt_clock);
qemu-user.c +0 -20
@@ -35,23 +35,3 @@ void monitor_vprintf(Monitor *mon, const char *fmt, va_list ap)void monitor_set_error (Monitor *mon,QError *qerror) { } - -int monitor_fdset_get_fd (int64_t fdset_id,int flags) -{ -return -1 ; -} - -int monitor_fdset_dup_fd_add (int64_t fdset_id,int dup_fd) -{ -return -1 ; -} - -int monitor_fdset_dup_fd_remove (int dup_fd) -{ -return -1 ; -} - -int monitor_fdset_dup_fd_find (int dup_fd) -{ -return -1 ; -}
Signature · 1 line
1.7.12.1
PATCH 6/11 iohandler: add weak alias in qemu-sockets.c, for qemu-ga
In reply to Paolo Bonzini--- qemu-sockets.c | 11 +++++++++++
1 file modificato, 11 inserzioni(+)
qemu-sockets.c +11 -0
@@ -974,3 +974,14 @@ static int default_monitor_get_fd(Monitor *mon, const char *name, Error **errp)return -1 ; }QEMU_WEAK_ALIAS (monitor_get_fd, default_monitor_get_fd); + +static int default_qemu_set_fd_handler2 (int fd, +IOCanReadHandler *fd_read_poll, +IOHandler *fd_read, +IOHandler *fd_write, +void *opaque) + +{ +abort (); +} +QEMU_WEAK_ALIAS (qemu_set_fd_handler2, default_qemu_set_fd_handler2);
Signature · 1 line
1.7.12.1
PATCH 7/11 win32: add weak version of qemu_fd_register
In reply to Paolo Bonzini--- oslib-win32.c | 5 +++++
1 file modificato, 5 inserzioni(+)
oslib-win32.c +5 -0
@@ -150,3 +150,8 @@ int qemu_get_thread_id(void) {return GetCurrentThreadId (); } + +static void default_qemu_fd_register (int fd) +{ +} +QEMU_WEAK_ALIAS (qemu_fd_register, default_qemu_fd_register);
Signature · 1 line
1.7.12.1
PATCH 8/11 qemu-timer: make initialization functions idempotent
In reply to Paolo Bonzini--- qemu-timer.c | 12 +++++++++---
1 file modificato, 9 inserzioni(+), 3 rimozioni(-)
qemu-timer.c +9 -3
@@ -430,9 +430,11 @@ void qemu_unregister_clock_reset_notifier(QEMUClock *clock, Notifier *notifier)void init_clocks (void ) { - rt_clock =qemu_new_clock (QEMU_CLOCK_REALTIME ); - vm_clock =qemu_new_clock (QEMU_CLOCK_VIRTUAL ); - host_clock =qemu_new_clock (QEMU_CLOCK_HOST ); +if (!rt_clock) { + rt_clock =qemu_new_clock (QEMU_CLOCK_REALTIME ); + vm_clock =qemu_new_clock (QEMU_CLOCK_VIRTUAL ); + host_clock =qemu_new_clock (QEMU_CLOCK_HOST ); + } }uint64_t qemu_timer_expire_time_ns (QEMUTimer *ts)
@@ -745,6 +747,10 @@ int init_timer_alarm(void)struct qemu_alarm_timer *t =NULL ;int i, err =-1 ; +if (alarm_timer) { +return 0 ; + } +for (i =0 ; alarm_timers[i].name; i++) { t = &alarm_timers[i];
Signature · 1 line
1.7.12.1
PATCH 9/11 main-loop: unify qemu_init_main_loop between QEMU and tools
In reply to Paolo Bonzini--- main-loop.c | 5 ++++- main-loop.h | 10 ---------- qemu-tool.c | 7 ------- vl.c | 5 -----
4 file modificati, 4 inserzioni(+), 23 rimozioni(-)
main-loop.c +4 -1
@@ -199,10 +199,13 @@ static int qemu_signal_init(void) }#endif -int main_loop_init (void ) +int qemu_init_main_loop (void ) {int ret; +init_clocks (); +init_timer_alarm (); +qemu_mutex_lock_iothread (); ret =qemu_signal_init ();if (ret) {
main-loop.h +0 -10
@@ -43,16 +43,6 @@int qemu_init_main_loop (void );/** -* main_loop_init: Initializes main loop -* -* Internal (but shared for compatibility reasons) initialization routine -* for the main loop. This should not be used by applications directly, -* use qemu_init_main_loop() instead. -* -*/ -int main_loop_init (void ); - -/** * main_loop_wait: Run one iteration of the main loop. * * If @nonblocking is true, poll for events, otherwise suspend until
qemu-tool.c +0 -7
@@ -92,13 +92,6 @@ void qemu_clock_warp(QEMUClock *clock) { } -int qemu_init_main_loop (void ) -{ -init_clocks (); -init_timer_alarm (); -return main_loop_init (); -} -void slirp_update_timeout (uint32_t *timeout) { }
vl.c +0 -5
@@ -2369,11 +2369,6 @@ static void free_and_trace(gpointer mem)free (mem); } -int qemu_init_main_loop (void ) -{ -return main_loop_init (); -} -int main (int argc,char **argv,char **envp) {int i;
Signature · 1 line
1.7.12.1
PATCH 10/11 qemu-tool: do not depend on qemu-timer.c
In reply to Paolo Bonzini--- qemu-tool.c | 2 +-
1 file modificato, 1 inserzione(+). 1 rimozione(-)
qemu-tool.c +1 -1
@@ -70,7 +70,7 @@ void monitor_protocol_event(MonitorEvent event, QObject *data)int64_t cpu_get_clock (void ) { -return qemu_get_clock_ns (rt_clock); +return get_clock_realtime (); }int64_t cpu_get_icount (void )
Signature · 1 line
1.7.12.1
PATCH 11/11 build: do not include main loop where it is not actually used
In reply to Paolo Bonzini--- Makefile | 6 +++--- Makefile.objs | 5 ++--- tests/Makefile | 4 ++--
3 file modificati, 7 inserzioni(+), 8 rimozioni(-)
Makefile +3 -3
@@ -171,7 +171,7 @@ endif qemu-img.o: qemu-img-cmds.h tools-obj-y = $(oslib-obj-y) $(trace-obj-y) qemu-tool.o qemu-timer.o \ - main-loop.o notify.o iohandler.o async.o error.o + main-loop.o iohandler.o error.o tools-obj-$(CONFIG_POSIX) += compatfd.o qemu-img$(EXESUF): qemu-img.o $(tools-obj-y) $(block-obj-y)
@@ -180,7 +180,7 @@ qemu-io$(EXESUF): qemu-io.o cmd.o $(tools-obj-y) $(block-obj-y) qemu-bridge-helper$(EXESUF): qemu-bridge-helper.o -vscclient$(EXESUF): $(libcacard-y) $(oslib-obj-y) $(trace-obj-y) $(tools-obj-y) qemu-timer-common.o libcacard/vscclient.o +vscclient$(EXESUF): $(libcacard-y) $(oslib-obj-y) $(trace-obj-y) libcacard/vscclient.o $(call quiet-command,$(CC) $(LDFLAGS) -o $@ $^ $(libcacard_libs) $(LIBS)," LINK $@") fsdev/virtfs-proxy-helper$(EXESUF): fsdev/virtfs-proxy-helper.o fsdev/virtio-9p-marshal.o oslib-posix.o $(trace-obj-y)
@@ -223,7 +223,7 @@ $(SRC_PATH)/qapi-schema.json $(SRC_PATH)/scripts/qapi-commands.py $(qapi-py) QGALIB_GEN=$(addprefix qga/qapi-generated/, qga-qapi-types.h qga-qapi-visit.h qga-qmp-commands.h) $(qga-obj-y) qemu-ga.o: $(QGALIB_GEN) -qemu-ga$(EXESUF): qemu-ga.o $(qga-obj-y) $(tools-obj-y) $(qapi-obj-y) $(qobject-obj-y) $(version-obj-y) +qemu-ga$(EXESUF): qemu-ga.o $(qga-obj-y) $(oslib-obj-y) $(trace-obj-y) $(qapi-obj-y) $(qobject-obj-y) $(version-obj-y) QEMULIBS=libuser libdis libdis-user
Makefile.objs +2 -3
@@ -228,9 +228,8 @@ universal-obj-y += $(qapi-obj-y) ###################################################################### # guest agent -qga-obj-y = qga/ qemu-ga.o module.o -qga-obj-$(CONFIG_WIN32) += oslib-win32.o -qga-obj-$(CONFIG_POSIX) += oslib-posix.o qemu-sockets.o qemu-option.o +qga-obj-y = qga/ qemu-ga.o module.o qemu-tool.o +qga-obj-$(CONFIG_POSIX) += qemu-sockets.o qemu-option.o vl.o: QEMU_CFLAGS+=$(GPROF_CFLAGS)
tests/Makefile +2 -2
@@ -47,8 +47,8 @@ tests/check-qstring$(EXESUF): tests/check-qstring.o qstring.o tests/check-qdict$(EXESUF): tests/check-qdict.o qdict.o qfloat.o qint.o qstring.o qbool.o qlist.o tests/check-qlist$(EXESUF): tests/check-qlist.o qlist.o qint.o tests/check-qfloat$(EXESUF): tests/check-qfloat.o qfloat.o -tests/check-qjson$(EXESUF): tests/check-qjson.o $(qobject-obj-y) $(tools-obj-y) -tests/test-coroutine$(EXESUF): tests/test-coroutine.o $(coroutine-obj-y) $(tools-obj-y) iov.o +tests/check-qjson$(EXESUF): tests/check-qjson.o $(qobject-obj-y) qemu-tool.o +tests/test-coroutine$(EXESUF): tests/test-coroutine.o $(coroutine-obj-y) $(block-obj-y) iov.o tests/test-iov$(EXESUF): tests/test-iov.o iov.o tests/test-qapi-types.c tests/test-qapi-types.h :\
Signature · 1 line
1.7.12.1