Received: from eggs.gnu.org ([2001:4830:134:3::10]:41163) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bjIhb-00083E-Hk for qemu-devel@nongnu.org; Mon, 12 Sep 2016 00:18:41 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bjIhY-000333-8V for qemu-devel@nongnu.org; Mon, 12 Sep 2016 00:18:39 -0400 Date: Mon, 12 Sep 2016 14:08:19 +1000 From: David Gibson Message-ID: <20160912040819.GB15077@voom.fritz.box> References: <1473361207-28498-1-git-send-email-lvivier@redhat.com> <1473361207-28498-3-git-send-email-lvivier@redhat.com> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="aVD9QWMuhilNxW9f" Content-Disposition: inline In-Reply-To: <1473361207-28498-3-git-send-email-lvivier@redhat.com> Subject: Re: [Qemu-devel] [PATCH v6 2/3] libqos: define SPAPR libqos functions List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Laurent Vivier Cc: thuth@redhat.com, qemu-ppc@nongnu.org, qemu-devel@nongnu.org, groug@kaod.org --aVD9QWMuhilNxW9f Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Thu, Sep 08, 2016 at 09:00:06PM +0200, Laurent Vivier wrote: > Define spapr_alloc_init()/spapr_alloc_init_flags()/spapr_alloc_uninit() >=20 > to allocate and use SPAPR guest memory >=20 > Define qtest_spapr_vboot()/qtest_spapr_boot()/qtest_spapr_shutdown() >=20 > to start SPAPR guest with QOSState initialized for it (memory managemen= t) >=20 > Move qtest_irq_intercept_in() from generic part to PC part. >=20 > Signed-off-by: Laurent Vivier > Reviewed-by: Greg Kurz Reviewed-by: David Gibson > --- > v6: > - rebase > - remove added include in tests/libqos/libqos.h > - add Greg's Rb >=20 > v5: > - replace "ppc64" by "spapr" > - Add test_spapr_vboot()/qtest_spapr_boot()/qtest_spapr_shutdown() > and remove machine_alloc_XXX() fuctions >=20 > tests/Makefile.include | 2 ++ > tests/libqos/libqos-pc.c | 2 ++ > tests/libqos/libqos-spapr.c | 30 ++++++++++++++++++++++++++++++ > tests/libqos/libqos-spapr.h | 10 ++++++++++ > tests/libqos/libqos.c | 1 - > tests/libqos/malloc-spapr.c | 38 ++++++++++++++++++++++++++++++++++++++ > tests/libqos/malloc-spapr.h | 17 +++++++++++++++++ > 7 files changed, 99 insertions(+), 1 deletion(-) > create mode 100644 tests/libqos/libqos-spapr.c > create mode 100644 tests/libqos/libqos-spapr.h > create mode 100644 tests/libqos/malloc-spapr.c > create mode 100644 tests/libqos/malloc-spapr.h >=20 > diff --git a/tests/Makefile.include b/tests/Makefile.include > index e3a3266..91df9f2 100644 > --- a/tests/Makefile.include > +++ b/tests/Makefile.include > @@ -576,6 +576,8 @@ tests/test-crypto-block$(EXESUF): tests/test-crypto-b= lock.o $(test-crypto-obj-y) > =20 > libqos-obj-y =3D tests/libqos/pci.o tests/libqos/fw_cfg.o tests/libqos/m= alloc.o > libqos-obj-y +=3D tests/libqos/i2c.o tests/libqos/libqos.o > +libqos-spapr-obj-y =3D $(libqos-obj-y) tests/libqos/malloc-spapr.o > +libqos-spapr-obj-y +=3D tests/libqos/libqos-spapr.o > libqos-pc-obj-y =3D $(libqos-obj-y) tests/libqos/pci-pc.o > libqos-pc-obj-y +=3D tests/libqos/malloc-pc.o tests/libqos/libqos-pc.o > libqos-pc-obj-y +=3D tests/libqos/ahci.o > diff --git a/tests/libqos/libqos-pc.c b/tests/libqos/libqos-pc.c > index 72b5e3b..df34092 100644 > --- a/tests/libqos/libqos-pc.c > +++ b/tests/libqos/libqos-pc.c > @@ -21,6 +21,8 @@ QOSState *qtest_pc_boot(const char *cmdline_fmt, ...) > qs =3D qtest_vboot(&qos_ops, cmdline_fmt, ap); > va_end(ap); > =20 > + qtest_irq_intercept_in(global_qtest, "ioapic"); > + > return qs; > } > =20 > diff --git a/tests/libqos/libqos-spapr.c b/tests/libqos/libqos-spapr.c > new file mode 100644 > index 0000000..f19408b > --- /dev/null > +++ b/tests/libqos/libqos-spapr.c > @@ -0,0 +1,30 @@ > +#include "qemu/osdep.h" > +#include "libqos/libqos-spapr.h" > +#include "libqos/malloc-spapr.h" > + > +static QOSOps qos_ops =3D { > + .init_allocator =3D spapr_alloc_init_flags, > + .uninit_allocator =3D spapr_alloc_uninit > +}; > + > +QOSState *qtest_spapr_vboot(const char *cmdline_fmt, va_list ap) > +{ > + return qtest_vboot(&qos_ops, cmdline_fmt, ap); > +} > + > +QOSState *qtest_spapr_boot(const char *cmdline_fmt, ...) > +{ > + QOSState *qs; > + va_list ap; > + > + va_start(ap, cmdline_fmt); > + qs =3D qtest_vboot(&qos_ops, cmdline_fmt, ap); > + va_end(ap); > + > + return qs; > +} > + > +void qtest_spapr_shutdown(QOSState *qs) > +{ > + return qtest_shutdown(qs); > +} > diff --git a/tests/libqos/libqos-spapr.h b/tests/libqos/libqos-spapr.h > new file mode 100644 > index 0000000..dcb5c43 > --- /dev/null > +++ b/tests/libqos/libqos-spapr.h > @@ -0,0 +1,10 @@ > +#ifndef LIBQOS_SPAPR_H > +#define LIBQOS_SPAPR_H > + > +#include "libqos/libqos.h" > + > +QOSState *qtest_spapr_vboot(const char *cmdline_fmt, va_list ap); > +QOSState *qtest_spapr_boot(const char *cmdline_fmt, ...); > +void qtest_spapr_shutdown(QOSState *qs); > + > +#endif > diff --git a/tests/libqos/libqos.c b/tests/libqos/libqos.c > index c7ba441..a852dc5 100644 > --- a/tests/libqos/libqos.c > +++ b/tests/libqos/libqos.c > @@ -20,7 +20,6 @@ QOSState *qtest_vboot(QOSOps *ops, const char *cmdline_= fmt, va_list ap) > cmdline =3D g_strdup_vprintf(cmdline_fmt, ap); > qs->qts =3D qtest_start(cmdline); > qs->ops =3D ops; > - qtest_irq_intercept_in(global_qtest, "ioapic"); > if (ops && ops->init_allocator) { > qs->alloc =3D ops->init_allocator(ALLOC_NO_FLAGS); > } > diff --git a/tests/libqos/malloc-spapr.c b/tests/libqos/malloc-spapr.c > new file mode 100644 > index 0000000..006404a > --- /dev/null > +++ b/tests/libqos/malloc-spapr.c > @@ -0,0 +1,38 @@ > +/* > + * libqos malloc support for SPAPR > + * > + * This work is licensed under the terms of the GNU GPL, version 2 or la= ter. > + * See the COPYING file in the top-level directory. > + */ > + > +#include "qemu/osdep.h" > +#include "libqos/malloc-spapr.h" > + > +#include "qemu-common.h" > + > +#define PAGE_SIZE 4096 > + > +/* Memory must be a multiple of 256 MB, > + * so we have at least 256MB > + */ > +#define SPAPR_MIN_SIZE 0x10000000 > + > +void spapr_alloc_uninit(QGuestAllocator *allocator) > +{ > + alloc_uninit(allocator); > +} > + > +QGuestAllocator *spapr_alloc_init_flags(QAllocOpts flags) > +{ > + QGuestAllocator *s; > + > + s =3D alloc_init_flags(flags, 1 << 20, SPAPR_MIN_SIZE); > + alloc_set_page_size(s, PAGE_SIZE); > + > + return s; > +} > + > +QGuestAllocator *spapr_alloc_init(void) > +{ > + return spapr_alloc_init_flags(ALLOC_NO_FLAGS); > +} > diff --git a/tests/libqos/malloc-spapr.h b/tests/libqos/malloc-spapr.h > new file mode 100644 > index 0000000..64d0e77 > --- /dev/null > +++ b/tests/libqos/malloc-spapr.h > @@ -0,0 +1,17 @@ > +/* > + * libqos malloc support for SPAPR > + * > + * This work is licensed under the terms of the GNU GPL, version 2 or la= ter. > + * See the COPYING file in the top-level directory. > + */ > + > +#ifndef LIBQOS_MALLOC_SPAPR_H > +#define LIBQOS_MALLOC_SPAPR_H > + > +#include "libqos/malloc.h" > + > +QGuestAllocator *spapr_alloc_init(void); > +QGuestAllocator *spapr_alloc_init_flags(QAllocOpts flags); > +void spapr_alloc_uninit(QGuestAllocator *allocator); > + > +#endif --=20 David Gibson | I'll have my music baroque, and my code david AT gibson.dropbear.id.au | minimalist, thank you. NOT _the_ _other_ | _way_ _around_! http://www.ozlabs.org/~dgibson --aVD9QWMuhilNxW9f Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQIcBAEBAgAGBQJX1iozAAoJEGw4ysog2bOSEa8QAJY/95LdDXFZJV5sCUhhVLi9 YEXT+WiowMy9pXCl0H9izlyztzkz5XLAJ3/gupRDkuF3HwOXQk8CJ23DdQMIj/wZ J77H/MpEmqvMCqN1RRsyG/vmBlZ27Sib8rLuBlupRtXrFxPJnTyhgI35W/vXBDyk 97jbKpeCNQna2MSiU947IEu2ahyebFSVOo0EoL7RAlBXW3KKN9HDAqfwLZFYh9U7 lZPZQg4VIGhgpDWMP8zfXwmorQh1a7L6NW+/h2gVgt+wb1yM/H+c+C5yreg+BeET E+s9TXtaJyoH0RPvOCUYWnwDQBuPCogOHOZpOs1XxhIH3psBoN4O+moOcm/cMasI BqUVgswpDPB6pfeUqju/XEM8JgGEeKz8JnjQZI2i/CCQpwL5dY9ihtHi9OvBKFv7 UTXGjXtSMgyePFhZHQ7YWz8jEoUDtQAzVdx4UGMs9veDde+JN4MgeQY4wxjgf7wi faomzPYQjwpBuRky4AAXeVibpfJW2vUmny+Je5MXv1V8cmM1bxjbauDOZLjs43Ju Sl7MIFhvUK4FoQmnPEIC1zBvU66x8i1DoDPRUfq7hT8AjcORhsu6bpp0zhaLYEMG Bl48mePzftQdYKx7ZvzyX+YyC5tRSnv7rRoyj5za3g41A6szAUw5ubLQfNUCxKID vilE03vAc/iDBwSxQa5m =Eya/ -----END PGP SIGNATURE----- --aVD9QWMuhilNxW9f--