qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: John Snow <jsnow@redhat.com>
To: qemu-devel@nongnu.org
Cc: kwolf@redhat.com, marc.mari.barcelo@gmail.com, armbru@redhat.com,
	mreitz@redhat.com, stefanha@redhat.com,
	John Snow <jsnow@redhat.com>
Subject: [Qemu-devel] [PATCH 10/14] qtest/ahci: remove guest_malloc global
Date: Mon, 12 Jan 2015 22:34:35 -0500	[thread overview]
Message-ID: <1421120079-987-11-git-send-email-jsnow@redhat.com> (raw)
In-Reply-To: <1421120079-987-1-git-send-email-jsnow@redhat.com>

Make helper routines rely on the earmarked
guest allocator object with AHCIQState/QOSSTate instead.

Signed-off-by: John Snow <jsnow@redhat.com>
---
 tests/ahci-test.c | 18 +++++++++---------
 1 file changed, 9 insertions(+), 9 deletions(-)

diff --git a/tests/ahci-test.c b/tests/ahci-test.c
index 1981b6a..b84f942 100644
--- a/tests/ahci-test.c
+++ b/tests/ahci-test.c
@@ -32,7 +32,6 @@
 #include "libqos/libqos-pc.h"
 #include "libqos/ahci.h"
 #include "libqos/pci-pc.h"
-#include "libqos/malloc-pc.h"
 
 #include "qemu-common.h"
 #include "qemu/host-utils.h"
@@ -44,7 +43,6 @@
 #define TEST_IMAGE_SIZE    (64 * 1024 * 1024)
 
 /*** Globals ***/
-static QGuestAllocator *guest_malloc;
 static char tmp_path[] = "/tmp/qtest.XXXXXX";
 static bool ahci_pedantic;
 
@@ -92,6 +90,11 @@ static void string_bswap16(uint16_t *s, size_t bytes)
     }
 }
 
+static uint64_t ahci_alloc(AHCIQState *ahci, size_t bytes)
+{
+    return qmalloc(ahci->parent, bytes);
+}
+
 /**
  * Locate, verify, and return a handle to the AHCI device.
  */
@@ -154,9 +157,6 @@ static AHCIQState *ahci_boot(void)
     /* Verify that we have an AHCI device present. */
     s->dev = get_ahci_device(&s->fingerprint);
 
-    /* Stopgap: Copy the allocator reference */
-    guest_malloc = s->parent->alloc;
-
     return s;
 }
 
@@ -272,13 +272,13 @@ static void ahci_hba_enable(AHCIQState *ahci)
 
         /* Allocate Memory for the Command List Buffer & FIS Buffer */
         /* PxCLB space ... 0x20 per command, as in 4.2.2 p 36 */
-        clb = guest_alloc(guest_malloc, num_cmd_slots * 0x20);
+        clb = ahci_alloc(ahci, num_cmd_slots * 0x20);
         g_test_message("CLB: 0x%08x", clb);
         PX_WREG(i, AHCI_PX_CLB, clb);
         g_assert_cmphex(clb, ==, PX_RREG(i, AHCI_PX_CLB));
 
         /* PxFB space ... 0x100, as in 4.2.1 p 35 */
-        fb = guest_alloc(guest_malloc, 0x100);
+        fb = ahci_alloc(ahci, 0x100);
         g_test_message("FB: 0x%08x", fb);
         PX_WREG(i, AHCI_PX_FB, fb);
         g_assert_cmphex(fb, ==, PX_RREG(i, AHCI_PX_FB));
@@ -951,12 +951,12 @@ static void ahci_test_identify(AHCIQState *ahci)
 
     /* Create a Command Table buffer. 0x80 is the smallest with a PRDTL of 0. */
     /* We need at least one PRD, so round up to the nearest 0x80 multiple.    */
-    table = guest_alloc(guest_malloc, CMD_TBL_SIZ(1));
+    table = ahci_alloc(ahci, CMD_TBL_SIZ(1));
     g_assert(table);
     ASSERT_BIT_CLEAR(table, 0x7F);
 
     /* Create a data buffer ... where we will dump the IDENTIFY data to. */
-    data_ptr = guest_alloc(guest_malloc, 512);
+    data_ptr = ahci_alloc(ahci, 512);
     g_assert(data_ptr);
 
     /* Grab the Command List Buffer pointer */
-- 
1.9.3

  parent reply	other threads:[~2015-01-13  3:35 UTC|newest]

Thread overview: 34+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-01-13  3:34 [Qemu-devel] [PATCH 00/14] ahci-test preliminary refactoring John Snow
2015-01-13  3:34 ` [Qemu-devel] [PATCH 01/14] libqos: Split apart pc_alloc_init John Snow
2015-01-13  8:54   ` Marc Marí
2015-01-13 16:29     ` John Snow
2015-01-19 17:07   ` Paolo Bonzini
2015-01-13  3:34 ` [Qemu-devel] [PATCH 02/14] qtest/ahci: Create ahci.h John Snow
2015-01-19 17:06   ` Paolo Bonzini
2015-01-13  3:34 ` [Qemu-devel] [PATCH 03/14] libqos: create libqos.c John Snow
2015-01-19 17:11   ` Paolo Bonzini
2015-01-13  3:34 ` [Qemu-devel] [PATCH 04/14] libqos: add qtest_vboot John Snow
2015-01-19 17:01   ` Paolo Bonzini
2015-01-13  3:34 ` [Qemu-devel] [PATCH 05/14] libqos: add alloc_init_flags John Snow
2015-01-19 17:01   ` Paolo Bonzini
2015-01-13  3:34 ` [Qemu-devel] [PATCH 06/14] libqos: add pc specific interface John Snow
2015-01-19 17:03   ` Paolo Bonzini
2015-01-13  3:34 ` [Qemu-devel] [PATCH 07/14] qtest/ahci: Store hba_base in AHCIQState John Snow
2015-01-19 17:15   ` Paolo Bonzini
2015-01-13  3:34 ` [Qemu-devel] [PATCH 08/14] qtest/ahci: finalize AHCIQState consolidation John Snow
2015-01-19 17:16   ` Paolo Bonzini
2015-01-13  3:34 ` [Qemu-devel] [PATCH 09/14] qtest/ahci: remove pcibus global John Snow
2015-01-19 17:05   ` Paolo Bonzini
2015-01-13  3:34 ` John Snow [this message]
2015-01-19 17:07   ` [Qemu-devel] [PATCH 10/14] qtest/ahci: remove guest_malloc global Paolo Bonzini
2015-01-13  3:34 ` [Qemu-devel] [PATCH 11/14] libqos/ahci: Functional register helpers John Snow
2015-01-19 17:09   ` Paolo Bonzini
2015-01-19 17:36     ` John Snow
2015-01-13  3:34 ` [Qemu-devel] [PATCH 12/14] qtest/ahci: remove getter/setter macros John Snow
2015-01-19 17:10   ` Paolo Bonzini
2015-01-13  3:34 ` [Qemu-devel] [PATCH 13/14] qtest/ahci: Bookmark FB and CLB pointers John Snow
2015-01-19 17:10   ` Paolo Bonzini
2015-01-13  3:34 ` [Qemu-devel] [PATCH 14/14] libqos/ahci: create libqos/ahci.c John Snow
2015-01-19 17:15   ` Paolo Bonzini
2015-01-19 17:48     ` John Snow
2015-01-19 17:59     ` Markus Armbruster

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1421120079-987-11-git-send-email-jsnow@redhat.com \
    --to=jsnow@redhat.com \
    --cc=armbru@redhat.com \
    --cc=kwolf@redhat.com \
    --cc=marc.mari.barcelo@gmail.com \
    --cc=mreitz@redhat.com \
    --cc=qemu-devel@nongnu.org \
    --cc=stefanha@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).