qemu-file: Move QEMUFileOps implementations to separate files
cover qemu-file: Move QEMUFileOps implementations to separate files
With this, code that uses symbols from qemu-file.c don't need to bring extra dependencies because of the actual QEMUFile operation implementations.
Eduardo Habkost (4):
qemu-file: Make qemu_file_is_writable() non-static
qemu-file: Use qemu_file_is_writable() on stdio_fclose()
qemu-file: Move unix and socket implementations to qemu-file-unix.c
qemu-file: Move stdio implementation to qemu-file-stdio.c
Makefile.objs | 2 +- include/migration/qemu-file.h | 1 + qemu-file-stdio.c | 194 ++++++++++++++++++++++ qemu-file-unix.c | 223 ++++++++++++++++++++++++++ qemu-file.c | 365 +----------------------------------------- tests/Makefile | 2 +- 6 files changed, 421 insertions(+), 366 deletions(-) create mode 100644 qemu-file-stdio.c create mode 100644 qemu-file-unix.c
Signature · 1 line
1.9.3
PATCH 1/4 qemu-file: Make qemu_file_is_writable() non-static
The QEMUFileStdio code will use qemu_file_is_writable() and will be moved to a separate file.
--- include/migration/qemu-file.h | 1 + qemu-file.c | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-)
include/migration/qemu-file.h +1 -0
@@ -110,6 +110,7 @@ void qemu_put_byte(QEMUFile *f, int v);*/ void qemu_put_buffer_async (QEMUFile *f,const uint8_t *buf,int size);bool qemu_file_mode_is_not_valid (const char *mode); +bool qemu_file_is_writable (QEMUFile *f);static inline void qemu_put_ubyte (QEMUFile *f,unsigned int v) {
qemu-file.c +1 -1
@@ -433,7 +433,7 @@ void qemu_file_set_error(QEMUFile *f, int ret) } } -static inline bool qemu_file_is_writable (QEMUFile *f) +bool qemu_file_is_writable (QEMUFile *f) {return f->ops->writev_buffer || f->ops->put_buffer; }
Signature · 1 line
1.9.3
PATCH 2/4 qemu-file: Use qemu_file_is_writable() on stdio_fclose()
In reply to Eduardo HabkostUse the existing function which checks if writev_buffer() or put_buffer() are set, instead of duplicating it.
--- qemu-file.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
qemu-file.c +1 -1
@@ -152,7 +152,7 @@ static int stdio_fclose(void *opaque)QEMUFileStdio *s = opaque;int ret =0 ; -if (s->file->ops->put_buffer || s->file->ops->writev_buffer) { +if (qemu_file_is_writable (s->file)) {int fd =fileno (s->stdio_file);struct stat st;
Signature · 1 line
1.9.3
PATCH 3/4 qemu-file: Move unix and socket implementations to qemu-file-unix.c
In reply to Eduardo HabkostSeparate the QEMUFile interface from the implementation, to reduce dependencies from code using QEMUFile.
All the code that is being moved to the new file is exactly the same code that was on savevm.c (moved by commit 093c455a8c6d8f715eabd8c8d346f08f17d686ec), so I am using the copyright and license header from savevm.c for the new file.
--- Makefile.objs | 2 +- qemu-file-unix.c | 223 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ qemu-file.c | 195 ------------------------------------------------ tests/Makefile | 2 +- 4 files changed, 225 insertions(+), 197 deletions(-) create mode 100644 qemu-file-unix.c
Makefile.objs +1 -1
@@ -50,7 +50,7 @@ common-obj-$(CONFIG_LINUX) += fsdev/ common-obj-y += migration.o migration-tcp.o common-obj-y += vmstate.o -common-obj-y += qemu-file.o +common-obj-y += qemu-file.o qemu-file-unix.o common-obj-$(CONFIG_RDMA) += migration-rdma.o common-obj-y += qemu-char.o #aio.o common-obj-y += block-migration.o
qemu-file-unix.c new file +223 -0
223 lines not on this page · raw message
qemu-file.c +0 -195
213 lines not on this page · raw message
tests/Makefile +1 -1
@@ -259,7 +259,7 @@ tests/test-qdev-global-props$(EXESUF): tests/test-qdev-global-props.o \ $(test-qapi-obj-y) \ libqemuutil.a libqemustub.a tests/test-vmstate$(EXESUF): tests/test-vmstate.o \ - vmstate.o qemu-file.o \ + vmstate.o qemu-file.o qemu-file-unix.o \ libqemuutil.a tests/test-qapi-types.c tests/test-qapi-types.h :\
Signature · 1 line
1.9.3
PATCH 4/4 qemu-file: Move stdio implementation to qemu-file-stdio.c
In reply to Eduardo HabkostSeparate the QEMUFile interface from the stdio-specific implementation, to reduce dependencies from code using QEMUFile.
The code that is being moved is similar to the one that was on savevm.c before it was moved in commit 093c455a8c6d8f715eabd8c8d346f08f17d686ec, except for some changes done by Markus, Juan, and myself. So, I am using the copyright and license header from savevm.c, but CCing Juan and Markus so they can review the copyright/license header.
--- Makefile.objs | 2 +- qemu-file-stdio.c | 194 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ qemu-file.c | 168 ---------------------------------------------- 3 files changed, 195 insertions(+), 169 deletions(-) create mode 100644 qemu-file-stdio.c
Makefile.objs +1 -1
@@ -50,7 +50,7 @@ common-obj-$(CONFIG_LINUX) += fsdev/ common-obj-y += migration.o migration-tcp.o common-obj-y += vmstate.o -common-obj-y += qemu-file.o qemu-file-unix.o +common-obj-y += qemu-file.o qemu-file-unix.o qemu-file-stdio.o common-obj-$(CONFIG_RDMA) += migration-rdma.o common-obj-y += qemu-char.o #aio.o common-obj-y += block-migration.o
qemu-file-stdio.c new file +194 -0
194 lines not on this page · raw message
qemu-file.c +0 -168
180 lines not on this page · raw message
Signature · 1 line
1.9.3
Quoted 2 lines · Eduardo Habkost
With this, code that uses symbols from
qemu-file.cdon't need to bring extra dependencies because of the actual QEMUFile operation implementations.
Each case of omitting the "extra dependencies" should be visible in makefiles as "prerequisites include qemu-file.o, but not all qemu-file-*.o". I can see one: tests/Makefile has just qemu-file-unix.o, but not qemu-file-stdio.o. Out of curiosity: will there be more?
Regardless:
Quoted 10 lines · Markus Armbruster
Quoted 2 lines · Eduardo Habkost
With this, code that uses symbols from
qemu-file.cdon't need to bring extra dependencies because of the actual QEMUFile operation implementations.Each case of omitting the "extra dependencies" should be visible in makefiles as "prerequisites include qemu-file.o, but not all qemu-file-*.o". I can see one: tests/Makefile has just qemu-file-unix.o, but not qemu-file-stdio.o. Out of curiosity: will there be more?
Yes, tests/test-x86-cpu[1] will only need qemu-file.o. That was the original motivation for this series.
[1] See Subject: [PATCH v2 0/7] Target-specific unit test support, add unit tests for target-i386/cpu.c code
Signature · 1 line
Eduardo
Quoted 8 lines · Eduardo Habkost
With this, code that uses symbols from
qemu-file.cdon't need to bring extra dependencies because of the actual QEMUFile operation implementations.Eduardo Habkost (4):
qemu-file: Makeqemu_file_is_writable()non-static
qemu-file: Useqemu_file_is_writable()onstdio_fclose()
qemu-file: Move unix and socket implementations toqemu-file-unix.c
qemu-file: Move stdio implementation toqemu-file-stdio.c
Applied. Minor conflicts with David qemu-file on buffer on Makefiles handled by me.