Received: from eggs.gnu.org ([2001:4830:134:3::10]:48639) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XCpsf-0005hg-CA for qemu-devel@nongnu.org; Thu, 31 Jul 2014 08:54:58 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1XCpsW-0005O6-28 for qemu-devel@nongnu.org; Thu, 31 Jul 2014 08:54:49 -0400 Received: from mail-we0-x232.google.com ([2a00:1450:400c:c03::232]:54365) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XCpsV-0005Nj-Rg for qemu-devel@nongnu.org; Thu, 31 Jul 2014 08:54:39 -0400 Received: by mail-we0-f178.google.com with SMTP id w61so2771495wes.37 for ; Thu, 31 Jul 2014 05:54:38 -0700 (PDT) Date: Thu, 31 Jul 2014 13:54:34 +0100 From: Stefan Hajnoczi Message-ID: <20140731125434.GZ25929@stefanha-thinkpad.redhat.com> References: <1404757089-4836-1-git-send-email-jsnow@redhat.com> <1404757089-4836-24-git-send-email-jsnow@redhat.com> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="ZljC5FVPx7rxDQQ8" Content-Disposition: inline In-Reply-To: <1404757089-4836-24-git-send-email-jsnow@redhat.com> Subject: Re: [Qemu-devel] [PATCH 23/28] ahci: Adding basic functionality qtest. List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: John Snow Cc: pbonzini@redhat.com, qemu-devel@nongnu.org, stefanha@redhat.com, mst@redhat.com --ZljC5FVPx7rxDQQ8 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline On Mon, Jul 07, 2014 at 02:18:04PM -0400, John Snow wrote: > +/* To help make it clear that the HBA is not a pointer to local memory. */ > +typedef void HBA; Unused. Please drop it or move it to the patch that uses it. > +static void free_ahci_device(QPCIDevice *ahci) > +{ > + if (pcibus) { > + qpci_free_pc(pcibus); > + pcibus = NULL; > + } > + > + /* libqos doesn't have a function for this, so free it manually */ > + g_free(ahci); Since the AHCI QPCIDevice comes from the QPCIBus, it would make sense to free the AHCI device before freeing the bus. > +} > + > +/*** Test Setup & Teardown ***/ > + > +/** > + * Launch QEMU with the given command line, > + * and then set up interrupts and our guest malloc interface. > + */ > +static void qtest_boot(const char *cmdline_fmt, ...) > +{ > + va_list ap; > + char *cmdline; > + > + va_start(ap, cmdline_fmt); > + cmdline = g_strdup_vprintf(cmdline_fmt, ap); > + va_end(ap); > + > + qtest_start(cmdline); > + qtest_irq_intercept_in(global_qtest, "ioapic"); > + guest_malloc = pc_alloc_init(); > + > + free(cmdline); g_strdup_vprintf() needs g_free(), not free(). > +} > + > +/** > + * Tear down the QEMU instance. > + */ > +static void qtest_shutdown(void) > +{ > + if (guest_malloc) { > + g_free(guest_malloc); > + guest_malloc = NULL; > + } g_free(NULL) is a nop, so this is equivalent: g_free(guest_malloc); guest_malloc = NULL; > + qtest_end(); > +} > + > +/** > + * Start a Q35 machine and bookmark a handle to the AHCI device. > + */ > +static void ahci_boot(QPCIDevice **ahci) > +{ > + QPCIDevice *dev; > + > + qtest_boot("-drive if=none,id=drive0,file=%s,cache=writeback,serial=%s" > + " -M q35 " > + "-device ide-hd,drive=drive0 " > + "-global ide-hd.ver=%s", > + tmp_path, "testdisk", "version"); > + > + /* Verify that we have an AHCI device present. */ > + dev = get_ahci_device(); > + > + if (ahci) { > + *ahci = dev; > + } It would be simpler to just return the QPCIDevice. --ZljC5FVPx7rxDQQ8 Content-Type: application/pgp-signature -----BEGIN PGP SIGNATURE----- Version: GnuPG v1 iQEcBAEBAgAGBQJT2jyKAAoJEJykq7OBq3PI40gIALYg7ju7n+LcVDsBqy50cqvL h4fp+1mcXx/0X/pKGA8db08Tct3Y9in5SsN6POPZHokIw8F6FzR8zODgCKxh+YkX ZZPMw2YLJ9Dz/7qWbXOoM1Jhw1oJZBZ5RzcfMHsKkx3acub0pPvBWT3LshM2M4A2 4qOtDfNqlyLEkfs4plDpP8z9QW9FXnneHV1cGCnmV3NSmsldVa6V+V2/jYUEPaTQ CG86S42fDYJqCSwdnrziar/j6L4SvdMSyhqT15z4j3xODWNWlVYmg2UqoAxHO+z1 RgNj7Mf/YDrIBiknPe+8l7T4Snctq6maDNdwzua76qC9xEVM1onxG3ldMQnFE8I= =9kZf -----END PGP SIGNATURE----- --ZljC5FVPx7rxDQQ8--