Message ID | 1473086312-4154-2-git-send-email-lvivier@redhat.com (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
On 05.09.2016 16:38, Laurent Vivier wrote: > And add support for ppc64. > > Signed-off-by: Laurent Vivier <lvivier@redhat.com> > --- > tests/Makefile.include | 3 ++- > tests/libqos/libqos.h | 2 +- > tests/libqos/malloc-ppc64.c | 38 ++++++++++++++++++++++++++++++++++++++ > tests/libqos/malloc-ppc64.h | 17 +++++++++++++++++ > tests/libqos/malloc.c | 42 ++++++++++++++++++++++++++++++++++++++++++ > tests/libqos/malloc.h | 3 +++ > 6 files changed, 103 insertions(+), 2 deletions(-) > create mode 100644 tests/libqos/malloc-ppc64.c > create mode 100644 tests/libqos/malloc-ppc64.h > > diff --git a/tests/Makefile.include b/tests/Makefile.include > index 14be491..a286848 100644 > --- a/tests/Makefile.include > +++ b/tests/Makefile.include > @@ -557,8 +557,9 @@ tests/test-crypto-block$(EXESUF): tests/test-crypto-block.o $(test-crypto-obj-y) > > libqos-obj-y = tests/libqos/pci.o tests/libqos/fw_cfg.o tests/libqos/malloc.o > libqos-obj-y += tests/libqos/i2c.o tests/libqos/libqos.o > +libqos-obj-y += tests/libqos/malloc-ppc64.o tests/libqos/malloc-pc.o Maybe this could rather be put into a libqos-malloc-obj-y variable which is then used to link these only to the tests that really need them? > libqos-pc-obj-y = $(libqos-obj-y) tests/libqos/pci-pc.o > -libqos-pc-obj-y += tests/libqos/malloc-pc.o tests/libqos/libqos-pc.o > +libqos-pc-obj-y += tests/libqos/libqos-pc.o > libqos-pc-obj-y += tests/libqos/ahci.o > libqos-omap-obj-y = $(libqos-obj-y) tests/libqos/i2c-omap.o > libqos-imx-obj-y = $(libqos-obj-y) tests/libqos/i2c-imx.o > diff --git a/tests/libqos/libqos.h b/tests/libqos/libqos.h > index 604980d..7b71607 100644 > --- a/tests/libqos/libqos.h > +++ b/tests/libqos/libqos.h > @@ -3,7 +3,7 @@ > > #include "libqtest.h" > #include "libqos/pci.h" > -#include "libqos/malloc-pc.h" > +#include "libqos/malloc.h" > > typedef struct QOSOps { > QGuestAllocator *(*init_allocator)(QAllocOpts); > diff --git a/tests/libqos/malloc-ppc64.c b/tests/libqos/malloc-ppc64.c > new file mode 100644 > index 0000000..33fd33f > --- /dev/null > +++ b/tests/libqos/malloc-ppc64.c > @@ -0,0 +1,38 @@ > +/* > + * libqos malloc support for PPC64 > + * > + * This work is licensed under the terms of the GNU GPL, version 2 or later. > + * See the COPYING file in the top-level directory. > + */ > + > +#include "qemu/osdep.h" > +#include "libqos/malloc-ppc64.h" > + > +#include "qemu-common.h" > + > +#define PAGE_SIZE (4096) No need for parenthesis here. > +/* Memory must be a multiple of 256 MB, > + * so we have at least 256MB > + */ > +#define PPC64_MIN_SIZE 0x10000000 > + > +void ppc64_alloc_uninit(QGuestAllocator *allocator) > +{ > + alloc_uninit(allocator); > +} > + > +QGuestAllocator *ppc64_alloc_init_flags(QAllocOpts flags) > +{ > + QGuestAllocator *s; > + > + s = alloc_init_flags(flags, 1 << 20, PPC64_MIN_SIZE); > + alloc_set_page_size(s, PAGE_SIZE); > + > + return s; > +} > + > +inline QGuestAllocator *ppc64_alloc_init(void) > +{ > + return ppc64_alloc_init_flags(ALLOC_NO_FLAGS); > +} Why is this function marked as inline? ... it is the last function in the source file... Apart from that, the patch looks fine to me. Thomas
On 05/09/2016 18:00, Thomas Huth wrote: > On 05.09.2016 16:38, Laurent Vivier wrote: >> And add support for ppc64. >> >> Signed-off-by: Laurent Vivier <lvivier@redhat.com> >> --- >> tests/Makefile.include | 3 ++- >> tests/libqos/libqos.h | 2 +- >> tests/libqos/malloc-ppc64.c | 38 ++++++++++++++++++++++++++++++++++++++ >> tests/libqos/malloc-ppc64.h | 17 +++++++++++++++++ >> tests/libqos/malloc.c | 42 ++++++++++++++++++++++++++++++++++++++++++ >> tests/libqos/malloc.h | 3 +++ >> 6 files changed, 103 insertions(+), 2 deletions(-) >> create mode 100644 tests/libqos/malloc-ppc64.c >> create mode 100644 tests/libqos/malloc-ppc64.h >> >> diff --git a/tests/Makefile.include b/tests/Makefile.include >> index 14be491..a286848 100644 >> --- a/tests/Makefile.include >> +++ b/tests/Makefile.include >> @@ -557,8 +557,9 @@ tests/test-crypto-block$(EXESUF): tests/test-crypto-block.o $(test-crypto-obj-y) >> >> libqos-obj-y = tests/libqos/pci.o tests/libqos/fw_cfg.o tests/libqos/malloc.o >> libqos-obj-y += tests/libqos/i2c.o tests/libqos/libqos.o >> +libqos-obj-y += tests/libqos/malloc-ppc64.o tests/libqos/malloc-pc.o > > Maybe this could rather be put into a libqos-malloc-obj-y variable which > is then used to link these only to the tests that really need them? Good idea. > >> libqos-pc-obj-y = $(libqos-obj-y) tests/libqos/pci-pc.o >> -libqos-pc-obj-y += tests/libqos/malloc-pc.o tests/libqos/libqos-pc.o >> +libqos-pc-obj-y += tests/libqos/libqos-pc.o >> libqos-pc-obj-y += tests/libqos/ahci.o >> libqos-omap-obj-y = $(libqos-obj-y) tests/libqos/i2c-omap.o >> libqos-imx-obj-y = $(libqos-obj-y) tests/libqos/i2c-imx.o >> diff --git a/tests/libqos/libqos.h b/tests/libqos/libqos.h >> index 604980d..7b71607 100644 >> --- a/tests/libqos/libqos.h >> +++ b/tests/libqos/libqos.h >> @@ -3,7 +3,7 @@ >> >> #include "libqtest.h" >> #include "libqos/pci.h" >> -#include "libqos/malloc-pc.h" >> +#include "libqos/malloc.h" >> >> typedef struct QOSOps { >> QGuestAllocator *(*init_allocator)(QAllocOpts); >> diff --git a/tests/libqos/malloc-ppc64.c b/tests/libqos/malloc-ppc64.c >> new file mode 100644 >> index 0000000..33fd33f >> --- /dev/null >> +++ b/tests/libqos/malloc-ppc64.c >> @@ -0,0 +1,38 @@ >> +/* >> + * libqos malloc support for PPC64 >> + * >> + * This work is licensed under the terms of the GNU GPL, version 2 or later. >> + * See the COPYING file in the top-level directory. >> + */ >> + >> +#include "qemu/osdep.h" >> +#include "libqos/malloc-ppc64.h" >> + >> +#include "qemu-common.h" >> + >> +#define PAGE_SIZE (4096) > > No need for parenthesis here. You really don't like parenthesis... > >> +/* Memory must be a multiple of 256 MB, >> + * so we have at least 256MB >> + */ >> +#define PPC64_MIN_SIZE 0x10000000 >> + >> +void ppc64_alloc_uninit(QGuestAllocator *allocator) >> +{ >> + alloc_uninit(allocator); >> +} >> + >> +QGuestAllocator *ppc64_alloc_init_flags(QAllocOpts flags) >> +{ >> + QGuestAllocator *s; >> + >> + s = alloc_init_flags(flags, 1 << 20, PPC64_MIN_SIZE); >> + alloc_set_page_size(s, PAGE_SIZE); >> + >> + return s; >> +} >> + >> +inline QGuestAllocator *ppc64_alloc_init(void) >> +{ >> + return ppc64_alloc_init_flags(ALLOC_NO_FLAGS); >> +} > > Why is this function marked as inline? ... it is the last function in > the source file... stupidly copied from tests/libqos/malloc-generic.c > > Apart from that, the patch looks fine to me. Thanks, Laurent
On 05.09.2016 18:48, Laurent Vivier wrote: > > > On 05/09/2016 18:00, Thomas Huth wrote: >> On 05.09.2016 16:38, Laurent Vivier wrote: >>> And add support for ppc64. >>> >>> Signed-off-by: Laurent Vivier <lvivier@redhat.com> >>> --- >>> tests/Makefile.include | 3 ++- >>> tests/libqos/libqos.h | 2 +- >>> tests/libqos/malloc-ppc64.c | 38 ++++++++++++++++++++++++++++++++++++++ >>> tests/libqos/malloc-ppc64.h | 17 +++++++++++++++++ >>> tests/libqos/malloc.c | 42 ++++++++++++++++++++++++++++++++++++++++++ >>> tests/libqos/malloc.h | 3 +++ >>> 6 files changed, 103 insertions(+), 2 deletions(-) >>> create mode 100644 tests/libqos/malloc-ppc64.c >>> create mode 100644 tests/libqos/malloc-ppc64.h >>> >>> diff --git a/tests/Makefile.include b/tests/Makefile.include >>> index 14be491..a286848 100644 >>> --- a/tests/Makefile.include >>> +++ b/tests/Makefile.include >>> @@ -557,8 +557,9 @@ tests/test-crypto-block$(EXESUF): tests/test-crypto-block.o $(test-crypto-obj-y) >>> >>> libqos-obj-y = tests/libqos/pci.o tests/libqos/fw_cfg.o tests/libqos/malloc.o >>> libqos-obj-y += tests/libqos/i2c.o tests/libqos/libqos.o >>> +libqos-obj-y += tests/libqos/malloc-ppc64.o tests/libqos/malloc-pc.o >> >> Maybe this could rather be put into a libqos-malloc-obj-y variable which >> is then used to link these only to the tests that really need them? > > Good idea. Thinking about this again, this maybe makes the Makefile more complex than it has to be ... so maybe it's better to keep it the way you did it in this patch. ... your choice! Thomas
diff --git a/tests/Makefile.include b/tests/Makefile.include index 14be491..a286848 100644 --- a/tests/Makefile.include +++ b/tests/Makefile.include @@ -557,8 +557,9 @@ tests/test-crypto-block$(EXESUF): tests/test-crypto-block.o $(test-crypto-obj-y) libqos-obj-y = tests/libqos/pci.o tests/libqos/fw_cfg.o tests/libqos/malloc.o libqos-obj-y += tests/libqos/i2c.o tests/libqos/libqos.o +libqos-obj-y += tests/libqos/malloc-ppc64.o tests/libqos/malloc-pc.o libqos-pc-obj-y = $(libqos-obj-y) tests/libqos/pci-pc.o -libqos-pc-obj-y += tests/libqos/malloc-pc.o tests/libqos/libqos-pc.o +libqos-pc-obj-y += tests/libqos/libqos-pc.o libqos-pc-obj-y += tests/libqos/ahci.o libqos-omap-obj-y = $(libqos-obj-y) tests/libqos/i2c-omap.o libqos-imx-obj-y = $(libqos-obj-y) tests/libqos/i2c-imx.o diff --git a/tests/libqos/libqos.h b/tests/libqos/libqos.h index 604980d..7b71607 100644 --- a/tests/libqos/libqos.h +++ b/tests/libqos/libqos.h @@ -3,7 +3,7 @@ #include "libqtest.h" #include "libqos/pci.h" -#include "libqos/malloc-pc.h" +#include "libqos/malloc.h" typedef struct QOSOps { QGuestAllocator *(*init_allocator)(QAllocOpts); diff --git a/tests/libqos/malloc-ppc64.c b/tests/libqos/malloc-ppc64.c new file mode 100644 index 0000000..33fd33f --- /dev/null +++ b/tests/libqos/malloc-ppc64.c @@ -0,0 +1,38 @@ +/* + * libqos malloc support for PPC64 + * + * This work is licensed under the terms of the GNU GPL, version 2 or later. + * See the COPYING file in the top-level directory. + */ + +#include "qemu/osdep.h" +#include "libqos/malloc-ppc64.h" + +#include "qemu-common.h" + +#define PAGE_SIZE (4096) + +/* Memory must be a multiple of 256 MB, + * so we have at least 256MB + */ +#define PPC64_MIN_SIZE 0x10000000 + +void ppc64_alloc_uninit(QGuestAllocator *allocator) +{ + alloc_uninit(allocator); +} + +QGuestAllocator *ppc64_alloc_init_flags(QAllocOpts flags) +{ + QGuestAllocator *s; + + s = alloc_init_flags(flags, 1 << 20, PPC64_MIN_SIZE); + alloc_set_page_size(s, PAGE_SIZE); + + return s; +} + +inline QGuestAllocator *ppc64_alloc_init(void) +{ + return ppc64_alloc_init_flags(ALLOC_NO_FLAGS); +} diff --git a/tests/libqos/malloc-ppc64.h b/tests/libqos/malloc-ppc64.h new file mode 100644 index 0000000..c2b2dff --- /dev/null +++ b/tests/libqos/malloc-ppc64.h @@ -0,0 +1,17 @@ +/* + * libqos malloc support for PPC64 + * + * This work is licensed under the terms of the GNU GPL, version 2 or later. + * See the COPYING file in the top-level directory. + */ + +#ifndef LIBQOS_MALLOC_PPC64_H +#define LIBQOS_MALLOC_PPC64_H + +#include "libqos/malloc.h" + +QGuestAllocator *ppc64_alloc_init(void); +QGuestAllocator *ppc64_alloc_init_flags(QAllocOpts flags); +void ppc64_alloc_uninit(QGuestAllocator *allocator); + +#endif diff --git a/tests/libqos/malloc.c b/tests/libqos/malloc.c index b8eff5f..6a02345 100644 --- a/tests/libqos/malloc.c +++ b/tests/libqos/malloc.c @@ -12,6 +12,9 @@ #include "qemu/osdep.h" #include "libqos/malloc.h" +#include "libqos/malloc-pc.h" +#include "libqos/malloc-ppc64.h" +#include "libqtest.h" #include "qemu-common.h" #include "qemu/host-utils.h" @@ -375,3 +378,42 @@ void migrate_allocator(QGuestAllocator *src, QTAILQ_INSERT_HEAD(src->free, node, MLIST_ENTNAME); return; } + +QGuestAllocator *machine_alloc_init(void) +{ + const char *arch = qtest_get_arch(); + + if (strcmp(arch, "i386") == 0 || strcmp(arch, "x86_64") == 0) { + return pc_alloc_init(); + } + if (strcmp(arch, "ppc64") == 0) { + return ppc64_alloc_init(); + } + return NULL; +} + +QGuestAllocator *machine_alloc_init_flags(QAllocOpts flags) +{ + const char *arch = qtest_get_arch(); + + if (strcmp(arch, "i386") == 0 || strcmp(arch, "x86_64") == 0) { + return pc_alloc_init_flags(flags); + } + if (strcmp(arch, "ppc64") == 0) { + return ppc64_alloc_init_flags(flags); + } + return NULL; +} + +void machine_alloc_uninit(QGuestAllocator *allocator) +{ + const char *arch = qtest_get_arch(); + + if (strcmp(arch, "i386") == 0 || strcmp(arch, "x86_64") == 0) { + pc_alloc_uninit(allocator); + return; + } + if (strcmp(arch, "ppc64") == 0) { + ppc64_alloc_uninit(allocator); + } +} diff --git a/tests/libqos/malloc.h b/tests/libqos/malloc.h index ae9dac8..a5f4c63 100644 --- a/tests/libqos/malloc.h +++ b/tests/libqos/malloc.h @@ -37,4 +37,7 @@ QGuestAllocator *alloc_init_flags(QAllocOpts flags, void alloc_set_page_size(QGuestAllocator *allocator, size_t page_size); void alloc_set_flags(QGuestAllocator *allocator, QAllocOpts opts); +QGuestAllocator *machine_alloc_init(void); +QGuestAllocator *machine_alloc_init_flags(QAllocOpts flags); +void machine_alloc_uninit(QGuestAllocator *allocator); #endif
And add support for ppc64. Signed-off-by: Laurent Vivier <lvivier@redhat.com> --- tests/Makefile.include | 3 ++- tests/libqos/libqos.h | 2 +- tests/libqos/malloc-ppc64.c | 38 ++++++++++++++++++++++++++++++++++++++ tests/libqos/malloc-ppc64.h | 17 +++++++++++++++++ tests/libqos/malloc.c | 42 ++++++++++++++++++++++++++++++++++++++++++ tests/libqos/malloc.h | 3 +++ 6 files changed, 103 insertions(+), 2 deletions(-) create mode 100644 tests/libqos/malloc-ppc64.c create mode 100644 tests/libqos/malloc-ppc64.h