qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: John Snow <jsnow@redhat.com>
To: qemu-block@nongnu.org
Cc: peter.maydell@linaro.org, qemu-devel@nongnu.org
Subject: Re: [Qemu-devel] [PATCH 3/3] qtest/ahci: use raw format when qemu-img is absent
Date: Fri, 13 Nov 2015 13:14:18 -0500	[thread overview]
Message-ID: <5646287A.7020203@redhat.com> (raw)
In-Reply-To: <1447357919-19452-4-git-send-email-jsnow@redhat.com>



On 11/12/2015 02:51 PM, John Snow wrote:
> If we don't have the qemu-img tool, use the raw format
> for tests and skip the high-sector LBA48 tests.
> 
> Signed-off-by: John Snow <jsnow@redhat.com>
> ---
>  tests/ahci-test.c | 41 ++++++++++++++++++++++++++++++++---------
>  1 file changed, 32 insertions(+), 9 deletions(-)
> 
> diff --git a/tests/ahci-test.c b/tests/ahci-test.c
> index 6d9ac84..7a4e375 100644
> --- a/tests/ahci-test.c
> +++ b/tests/ahci-test.c
> @@ -39,16 +39,16 @@
>  #include "hw/pci/pci_ids.h"
>  #include "hw/pci/pci_regs.h"
>  
> -/* Test-specific defines -- in MiB */
> -#define TEST_IMAGE_SIZE_MB (200 * 1024)
> -#define TEST_IMAGE_SECTORS ((TEST_IMAGE_SIZE_MB / AHCI_SECTOR_SIZE)     \
> -                            * 1024 * 1024)
> +/* Test images sizes in MB */
> +#define TEST_IMAGE_SIZE_MB_LARGE (200 * 1024)
> +#define TEST_IMAGE_SIZE_MB_SMALL 64
>  
>  /*** Globals ***/
>  static char tmp_path[] = "/tmp/qtest.XXXXXX";
>  static char debug_path[] = "/tmp/qtest-blkdebug.XXXXXX";
>  static bool ahci_pedantic;
>  static const char *imgfmt;
> +static unsigned test_image_size_mb;
>  
>  /*** Function Declarations ***/
>  static void ahci_test_port_spec(AHCIQState *ahci, uint8_t port);
> @@ -61,6 +61,11 @@ static void ahci_test_pmcap(AHCIQState *ahci, uint8_t offset);
>  
>  /*** Utilities ***/
>  
> +static size_t mb_to_sectors(size_t image_size_mb)
> +{
> +    return (image_size_mb * 1024 * 1024) / AHCI_SECTOR_SIZE;
> +}
> +

NACK, size_t is not sufficient for i386 where we need explicitly
uint64_t to fit LBA48 values.

>  static void string_bswap16(uint16_t *s, size_t bytes)
>  {
>      g_assert_cmphex((bytes & 1), ==, 0);
> @@ -901,7 +906,7 @@ static void ahci_test_max(AHCIQState *ahci)
>      uint64_t nsect;
>      uint8_t port;
>      uint8_t cmd;
> -    uint64_t config_sect = TEST_IMAGE_SECTORS - 1;
> +    uint64_t config_sect = mb_to_sectors(test_image_size_mb) - 1;
>  
>      if (config_sect > 0xFFFFFF) {
>          cmd = CMD_READ_MAX_EXT;
> @@ -1480,7 +1485,7 @@ static uint64_t offset_sector(enum OffsetType ofst,
>          return 1;
>      case OFFSET_HIGH:
>          ceil = (addr_type == ADDR_MODE_LBA28) ? 0xfffffff : 0xffffffffffff;
> -        ceil = MIN(ceil, TEST_IMAGE_SECTORS - 1);
> +        ceil = MIN(ceil, mb_to_sectors(test_image_size_mb) - 1);
>          nsectors = buffsize / AHCI_SECTOR_SIZE;
>          return ceil - nsectors + 1;
>      default:
> @@ -1562,8 +1567,9 @@ static void create_ahci_io_test(enum IOMode type, enum AddrMode addr,
>                                  enum BuffLen len, enum OffsetType offset)
>  {
>      char *name;
> -    AHCIIOTestOptions *opts = g_malloc(sizeof(AHCIIOTestOptions));
> +    AHCIIOTestOptions *opts;
>  
> +    opts = g_malloc(sizeof(AHCIIOTestOptions));
>      opts->length = len;
>      opts->address_type = addr;
>      opts->io_type = type;
> @@ -1575,6 +1581,13 @@ static void create_ahci_io_test(enum IOMode type, enum AddrMode addr,
>                             buff_len_str[len],
>                             offset_str[offset]);
>  
> +    if ((addr == ADDR_MODE_LBA48) && (offset == OFFSET_HIGH) &&
> +        (mb_to_sectors(test_image_size_mb) <= 0xFFFFFFF)) {
> +        g_test_message("%s: skipped; test image too small", name);
> +        g_free(name);
> +        return;
> +    }
> +
>      qtest_add_data_func(name, opts, test_io_interface);
>      g_free(name);
>  }
> @@ -1624,8 +1637,18 @@ int main(int argc, char **argv)
>      /* Create a temporary image */
>      fd = mkstemp(tmp_path);
>      g_assert(fd >= 0);
> -    imgfmt = "qcow2";
> -    mkqcow2(tmp_path, TEST_IMAGE_SIZE_MB);
> +    if (have_qemu_img()) {
> +        imgfmt = "qcow2";
> +        test_image_size_mb = TEST_IMAGE_SIZE_MB_LARGE;
> +        mkqcow2(tmp_path, TEST_IMAGE_SIZE_MB_LARGE);
> +    } else {
> +        g_test_message("QTEST_QEMU_IMG not set or qemu-img missing; "
> +                       "skipping LBA48 high-sector tests");
> +        imgfmt = "raw";
> +        test_image_size_mb = TEST_IMAGE_SIZE_MB_SMALL;
> +        ret = ftruncate(fd, test_image_size_mb * 1024 * 1024);
> +        g_assert(ret == 0);
> +    }
>      close(fd);
>  
>      /* Create temporary blkdebug instructions */
> 

      reply	other threads:[~2015-11-13 18:14 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-11-12 19:51 [Qemu-devel] [PATCH 0/3] qtest/ahci: skip qcow2 tests John Snow
2015-11-12 19:51 ` [Qemu-devel] [PATCH 1/3] qtest/ahci: always specify image format John Snow
2015-11-12 19:51 ` [Qemu-devel] [PATCH 2/3] libqos: add qemu-img presence check John Snow
2015-11-12 19:51 ` [Qemu-devel] [PATCH 3/3] qtest/ahci: use raw format when qemu-img is absent John Snow
2015-11-13 18:14   ` John Snow [this message]

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=5646287A.7020203@redhat.com \
    --to=jsnow@redhat.com \
    --cc=peter.maydell@linaro.org \
    --cc=qemu-block@nongnu.org \
    --cc=qemu-devel@nongnu.org \
    /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).