diff --git a/block/block-backend.c b/block/block-backend.c index d74f6701b5869ea70d2e1a1bb39c83c57cafe4dd..16c9d5e0f22700af4824c35b56eb1a7d14973cda 100644 --- a/block/block-backend.c +++ b/block/block-backend.c @@ -820,7 +820,7 @@ int blk_write_zeroes(BlockBackend *blk, int64_t sector_num, int nb_sectors, BdrvRequestFlags flags) { return blk_rw(blk, sector_num, NULL, nb_sectors, blk_write_entry, - BDRV_REQ_ZERO_WRITE); + flags | BDRV_REQ_ZERO_WRITE); } static void error_callback_bh(void *opaque) @@ -852,6 +852,7 @@ BlockAIOCB *blk_abort_aio_request(BlockBackend *blk, typedef struct BlkAioEmAIOCB { BlockAIOCB common; BlkRwCo rwco; + int bytes; bool has_returned; QEMUBH* bh; } BlkAioEmAIOCB; @@ -877,7 +878,7 @@ static void blk_aio_complete_bh(void *opaque) blk_aio_complete(opaque); } -static BlockAIOCB *blk_aio_prwv(BlockBackend *blk, int64_t offset, +static BlockAIOCB *blk_aio_prwv(BlockBackend *blk, int64_t offset, int bytes, QEMUIOVector *qiov, CoroutineEntry co_entry, BdrvRequestFlags flags, BlockCompletionFunc *cb, void *opaque) @@ -893,6 +894,7 @@ static BlockAIOCB *blk_aio_prwv(BlockBackend *blk, int64_t offset, .flags = flags, .ret = NOT_DONE, }; + acb->bytes = bytes; acb->bh = NULL; acb->has_returned = false; @@ -913,7 +915,8 @@ static void blk_aio_read_entry(void *opaque) BlkAioEmAIOCB *acb = opaque; BlkRwCo *rwco = &acb->rwco; - rwco->ret = blk_co_preadv(rwco->blk, rwco->offset, rwco->qiov->size, + assert(rwco->qiov->size == acb->bytes); + rwco->ret = blk_co_preadv(rwco->blk, rwco->offset, acb->bytes, rwco->qiov, rwco->flags); blk_aio_complete(acb); } @@ -923,8 +926,8 @@ static void blk_aio_write_entry(void *opaque) BlkAioEmAIOCB *acb = opaque; BlkRwCo *rwco = &acb->rwco; - rwco->ret = blk_co_pwritev(rwco->blk, rwco->offset, - rwco->qiov ? rwco->qiov->size : 0, + assert(!rwco->qiov || rwco->qiov->size == acb->bytes); + rwco->ret = blk_co_pwritev(rwco->blk, rwco->offset, acb->bytes, rwco->qiov, rwco->flags); blk_aio_complete(acb); } @@ -937,8 +940,10 @@ BlockAIOCB *blk_aio_write_zeroes(BlockBackend *blk, int64_t sector_num, return blk_abort_aio_request(blk, cb, opaque, -EINVAL); } - return blk_aio_prwv(blk, sector_num << BDRV_SECTOR_BITS, NULL, - blk_aio_write_entry, BDRV_REQ_ZERO_WRITE, cb, opaque); + return blk_aio_prwv(blk, sector_num << BDRV_SECTOR_BITS, + nb_sectors << BDRV_SECTOR_BITS, NULL, + blk_aio_write_entry, flags | BDRV_REQ_ZERO_WRITE, + cb, opaque); } int blk_pread(BlockBackend *blk, int64_t offset, void *buf, int count) @@ -994,7 +999,8 @@ BlockAIOCB *blk_aio_readv(BlockBackend *blk, int64_t sector_num, return blk_abort_aio_request(blk, cb, opaque, -EINVAL); } - return blk_aio_prwv(blk, sector_num << BDRV_SECTOR_BITS, iov, + assert(nb_sectors << BDRV_SECTOR_BITS == iov->size); + return blk_aio_prwv(blk, sector_num << BDRV_SECTOR_BITS, iov->size, iov, blk_aio_read_entry, 0, cb, opaque); } @@ -1006,7 +1012,8 @@ BlockAIOCB *blk_aio_writev(BlockBackend *blk, int64_t sector_num, return blk_abort_aio_request(blk, cb, opaque, -EINVAL); } - return blk_aio_prwv(blk, sector_num << BDRV_SECTOR_BITS, iov, + assert(nb_sectors << BDRV_SECTOR_BITS == iov->size); + return blk_aio_prwv(blk, sector_num << BDRV_SECTOR_BITS, iov->size, iov, blk_aio_write_entry, 0, cb, opaque); } @@ -1446,7 +1453,7 @@ int coroutine_fn blk_co_write_zeroes(BlockBackend *blk, int64_t sector_num, return blk_co_pwritev(blk, sector_num << BDRV_SECTOR_BITS, nb_sectors << BDRV_SECTOR_BITS, NULL, - BDRV_REQ_ZERO_WRITE); + flags | BDRV_REQ_ZERO_WRITE); } int blk_write_compressed(BlockBackend *blk, int64_t sector_num, diff --git a/block/vpc.c b/block/vpc.c index 3713ec3a5f56e6e9498e39ba1d1bb75ce8aa3197..3e2ea698d979846613cc7cf94899136fdc6f9fb0 100644 --- a/block/vpc.c +++ b/block/vpc.c @@ -45,34 +45,34 @@ enum vhd_type { VHD_DIFFERENCING = 4, }; -// Seconds since Jan 1, 2000 0:00:00 (UTC) +/* Seconds since Jan 1, 2000 0:00:00 (UTC) */ #define VHD_TIMESTAMP_BASE 946684800 #define VHD_CHS_MAX_C 65535LL #define VHD_CHS_MAX_H 16 #define VHD_CHS_MAX_S 255 -#define VHD_MAX_SECTORS (65535LL * 255 * 255) +#define VHD_MAX_SECTORS 0xff000000 /* 2040 GiB max image size */ #define VHD_MAX_GEOMETRY (VHD_CHS_MAX_C * VHD_CHS_MAX_H * VHD_CHS_MAX_S) #define VPC_OPT_FORCE_SIZE "force_size" -// always big-endian +/* always big-endian */ typedef struct vhd_footer { - char creator[8]; // "conectix" + char creator[8]; /* "conectix" */ uint32_t features; uint32_t version; - // Offset of next header structure, 0xFFFFFFFF if none + /* Offset of next header structure, 0xFFFFFFFF if none */ uint64_t data_offset; - // Seconds since Jan 1, 2000 0:00:00 (UTC) + /* Seconds since Jan 1, 2000 0:00:00 (UTC) */ uint32_t timestamp; - char creator_app[4]; // "vpc " + char creator_app[4]; /* e.g., "vpc " */ uint16_t major; uint16_t minor; - char creator_os[4]; // "Wi2k" + char creator_os[4]; /* "Wi2k" */ uint64_t orig_size; uint64_t current_size; @@ -83,29 +83,29 @@ typedef struct vhd_footer { uint32_t type; - // Checksum of the Hard Disk Footer ("one's complement of the sum of all - // the bytes in the footer without the checksum field") + /* Checksum of the Hard Disk Footer ("one's complement of the sum of all + the bytes in the footer without the checksum field") */ uint32_t checksum; - // UUID used to identify a parent hard disk (backing file) + /* UUID used to identify a parent hard disk (backing file) */ uint8_t uuid[16]; uint8_t in_saved_state; } QEMU_PACKED VHDFooter; typedef struct vhd_dyndisk_header { - char magic[8]; // "cxsparse" + char magic[8]; /* "cxsparse" */ - // Offset of next header structure, 0xFFFFFFFF if none + /* Offset of next header structure, 0xFFFFFFFF if none */ uint64_t data_offset; - // Offset of the Block Allocation Table (BAT) + /* Offset of the Block Allocation Table (BAT) */ uint64_t table_offset; uint32_t version; - uint32_t max_table_entries; // 32bit/entry + uint32_t max_table_entries; /* 32bit/entry */ - // 2 MB by default, must be a power of two + /* 2 MB by default, must be a power of two */ uint32_t block_size; uint32_t checksum; @@ -113,7 +113,7 @@ typedef struct vhd_dyndisk_header { uint32_t parent_timestamp; uint32_t reserved; - // Backing file name (in UTF-16) + /* Backing file name (in UTF-16) */ uint8_t parent_name[512]; struct { @@ -238,6 +238,7 @@ static int vpc_open(BlockDriverState *bs, QDict *options, int flags, ret = bdrv_pread(bs->file->bs, 0, s->footer_buf, HEADER_SIZE); if (ret < 0) { + error_setg(errp, "Unable to read VHD header"); goto fail; } @@ -246,9 +247,11 @@ static int vpc_open(BlockDriverState *bs, QDict *options, int flags, int64_t offset = bdrv_getlength(bs->file->bs); if (offset < 0) { ret = offset; + error_setg(errp, "Invalid file size"); goto fail; } else if (offset < HEADER_SIZE) { ret = -EINVAL; + error_setg(errp, "File too small for a VHD header"); goto fail; } @@ -275,9 +278,9 @@ static int vpc_open(BlockDriverState *bs, QDict *options, int flags, /* Write 'checksum' back to footer, or else will leave it with zero. */ footer->checksum = cpu_to_be32(checksum); - // The visible size of a image in Virtual PC depends on the geometry - // rather than on the size stored in the footer (the size in the footer - // is too large usually) + /* The visible size of a image in Virtual PC depends on the geometry + rather than on the size stored in the footer (the size in the footer + is too large usually) */ bs->total_sectors = (int64_t) be16_to_cpu(footer->cyls) * footer->heads * footer->secs_per_cyl; @@ -299,6 +302,8 @@ static int vpc_open(BlockDriverState *bs, QDict *options, int flags, * 'qem2' : current_size QEMU (uses current_size) * 'win ' : current_size Hyper-V * 'd2v ' : current_size Disk2vhd + * 'tap\0' : current_size XenServer + * 'CTXS' : current_size XenConverter * * The user can override the table values via drive options, however * even with an override we will still use current_size for images @@ -306,15 +311,17 @@ static int vpc_open(BlockDriverState *bs, QDict *options, int flags, */ use_chs = (!!strncmp(footer->creator_app, "win ", 4) && !!strncmp(footer->creator_app, "qem2", 4) && - !!strncmp(footer->creator_app, "d2v ", 4)) || s->force_use_chs; + !!strncmp(footer->creator_app, "d2v ", 4) && + !!strncmp(footer->creator_app, "CTXS", 4) && + !!memcmp(footer->creator_app, "tap", 4)) || s->force_use_chs; if (!use_chs || bs->total_sectors == VHD_MAX_GEOMETRY || s->force_use_sz) { bs->total_sectors = be64_to_cpu(footer->current_size) / BDRV_SECTOR_SIZE; } - /* Allow a maximum disk size of approximately 2 TB */ - if (bs->total_sectors >= VHD_MAX_SECTORS) { + /* Allow a maximum disk size of 2040 GiB */ + if (bs->total_sectors > VHD_MAX_SECTORS) { ret = -EFBIG; goto fail; } @@ -323,12 +330,14 @@ static int vpc_open(BlockDriverState *bs, QDict *options, int flags, ret = bdrv_pread(bs->file->bs, be64_to_cpu(footer->data_offset), buf, HEADER_SIZE); if (ret < 0) { + error_setg(errp, "Error reading dynamic VHD header"); goto fail; } dyndisk_header = (VHDDynDiskHeader *) buf; if (strncmp(dyndisk_header->magic, "cxsparse", 8)) { + error_setg(errp, "Invalid header magic"); ret = -EINVAL; goto fail; } @@ -344,16 +353,14 @@ static int vpc_open(BlockDriverState *bs, QDict *options, int flags, s->max_table_entries = be32_to_cpu(dyndisk_header->max_table_entries); if ((bs->total_sectors * 512) / s->block_size > 0xffffffffU) { - ret = -EINVAL; - goto fail; - } - if (s->max_table_entries > (VHD_MAX_SECTORS * 512) / s->block_size) { + error_setg(errp, "Too many blocks"); ret = -EINVAL; goto fail; } computed_size = (uint64_t) s->max_table_entries * s->block_size; if (computed_size < bs->total_sectors * 512) { + error_setg(errp, "Page table too small"); ret = -EINVAL; goto fail; } @@ -370,6 +377,7 @@ static int vpc_open(BlockDriverState *bs, QDict *options, int flags, s->pagetable = qemu_try_blockalign(bs->file->bs, pagetable_size); if (s->pagetable == NULL) { + error_setg(errp, "Unable to allocate memory for page table"); ret = -ENOMEM; goto fail; } @@ -379,6 +387,7 @@ static int vpc_open(BlockDriverState *bs, QDict *options, int flags, ret = bdrv_pread(bs->file->bs, s->bat_offset, s->pagetable, pagetable_size); if (ret < 0) { + error_setg(errp, "Error reading pagetable"); goto fail; } @@ -457,16 +466,16 @@ static inline int64_t get_sector_offset(BlockDriverState *bs, pageentry_index = (offset % s->block_size) / 512; if (pagetable_index >= s->max_table_entries || s->pagetable[pagetable_index] == 0xffffffff) - return -1; // not allocated + return -1; /* not allocated */ bitmap_offset = 512 * (uint64_t) s->pagetable[pagetable_index]; block_offset = bitmap_offset + s->bitmap_size + (512 * pageentry_index); - // We must ensure that we don't write to any sectors which are marked as - // unused in the bitmap. We get away with setting all bits in the block - // bitmap each time we write to a new block. This might cause Virtual PC to - // miss sparse read optimization, but it's not a problem in terms of - // correctness. + /* We must ensure that we don't write to any sectors which are marked as + unused in the bitmap. We get away with setting all bits in the block + bitmap each time we write to a new block. This might cause Virtual PC to + miss sparse read optimization, but it's not a problem in terms of + correctness. */ if (write && (s->last_bitmap_offset != bitmap_offset)) { uint8_t bitmap[s->bitmap_size]; @@ -512,18 +521,18 @@ static int64_t alloc_block(BlockDriverState* bs, int64_t sector_num) int ret; uint8_t bitmap[s->bitmap_size]; - // Check if sector_num is valid + /* Check if sector_num is valid */ if ((sector_num < 0) || (sector_num > bs->total_sectors)) return -1; - // Write entry into in-memory BAT + /* Write entry into in-memory BAT */ index = (sector_num * 512) / s->block_size; if (s->pagetable[index] != 0xFFFFFFFF) return -1; s->pagetable[index] = s->free_data_block_offset / 512; - // Initialize the block's bitmap + /* Initialize the block's bitmap */ memset(bitmap, 0xff, s->bitmap_size); ret = bdrv_pwrite_sync(bs->file->bs, s->free_data_block_offset, bitmap, s->bitmap_size); @@ -531,13 +540,13 @@ static int64_t alloc_block(BlockDriverState* bs, int64_t sector_num) return ret; } - // Write new footer (the old one will be overwritten) + /* Write new footer (the old one will be overwritten) */ s->free_data_block_offset += s->block_size + s->bitmap_size; ret = rewrite_footer(bs); if (ret < 0) goto fail; - // Write BAT entry to disk + /* Write BAT entry to disk */ bat_offset = s->bat_offset + (4 * index); bat_value = cpu_to_be32(s->pagetable[index]); ret = bdrv_pwrite_sync(bs->file->bs, bat_offset, &bat_value, 4); @@ -718,7 +727,7 @@ static int64_t coroutine_fn vpc_co_get_block_status(BlockDriverState *bs, * Note that the geometry doesn't always exactly match total_sectors but * may round it down. * - * Returns 0 on success, -EFBIG if the size is larger than ~2 TB. Override + * Returns 0 on success, -EFBIG if the size is larger than 2040 GiB. Override * the hardware EIDE and ATA-2 limit of 16 heads (max disk size of 127 GB) * and instead allow up to 255 heads. */ @@ -770,7 +779,7 @@ static int create_dynamic_disk(BlockBackend *blk, uint8_t *buf, int ret; int64_t offset = 0; - // Write the footer (twice: at the beginning and at the end) + /* Write the footer (twice: at the beginning and at the end) */ block_size = 0x200000; num_bat_entries = (total_sectors + block_size / 512) / (block_size / 512); @@ -785,7 +794,7 @@ static int create_dynamic_disk(BlockBackend *blk, uint8_t *buf, goto fail; } - // Write the initial BAT + /* Write the initial BAT */ offset = 3 * 512; memset(buf, 0xFF, 512); @@ -797,7 +806,7 @@ static int create_dynamic_disk(BlockBackend *blk, uint8_t *buf, offset += 512; } - // Prepare the Dynamic Disk Header + /* Prepare the Dynamic Disk Header */ memset(buf, 0, 1024); memcpy(dyndisk_header->magic, "cxsparse", 8); @@ -814,7 +823,7 @@ static int create_dynamic_disk(BlockBackend *blk, uint8_t *buf, dyndisk_header->checksum = cpu_to_be32(vpc_checksum(buf, 1024)); - // Write the header + /* Write the header */ offset = 512; ret = blk_pwrite(blk, offset, buf, 1024); @@ -874,6 +883,7 @@ static int vpc_create(const char *filename, QemuOpts *opts, Error **errp) } else if (!strcmp(disk_type_param, "fixed")) { disk_type = VHD_FIXED; } else { + error_setg(errp, "Invalid disk type, %s", disk_type_param); ret = -EINVAL; goto out; } @@ -922,8 +932,9 @@ static int vpc_create(const char *filename, QemuOpts *opts, Error **errp) if ((int64_t)cyls * heads * secs_per_cyl == VHD_MAX_GEOMETRY) { total_sectors = total_size / BDRV_SECTOR_SIZE; - /* Allow a maximum disk size of approximately 2 TB */ + /* Allow a maximum disk size of 2040 GiB */ if (total_sectors > VHD_MAX_SECTORS) { + error_setg(errp, "Disk size is too large, max size is 2040 GiB"); ret = -EFBIG; goto out; } @@ -974,6 +985,9 @@ static int vpc_create(const char *filename, QemuOpts *opts, Error **errp) } else { ret = create_fixed_disk(blk, buf, total_size); } + if (ret < 0) { + error_setg(errp, "Unable to create or write VHD header"); + } out: blk_unref(blk); diff --git a/hw/block/pflash_cfi01.c b/hw/block/pflash_cfi01.c index c475c2aea75bdf21b1c3bdd8bf3469634775574c..106a77523263c8e697d87b646c79d57082638ec1 100644 --- a/hw/block/pflash_cfi01.c +++ b/hw/block/pflash_cfi01.c @@ -46,6 +46,7 @@ #include "exec/address-spaces.h" #include "qemu/host-utils.h" #include "hw/sysbus.h" +#include "sysemu/sysemu.h" #define PFLASH_BUG(fmt, ...) \ do { \ @@ -97,6 +98,7 @@ struct pflash_t { MemoryRegion mem; char *name; void *storage; + VMChangeStateEntry *vmstate; }; static int pflash_post_load(void *opaque, int version_id); @@ -944,13 +946,25 @@ MemoryRegion *pflash_cfi01_get_memory(pflash_t *fl) return &fl->mem; } +static void postload_update_cb(void *opaque, int running, RunState state) +{ + pflash_t *pfl = opaque; + + /* This is called after bdrv_invalidate_cache_all. */ + qemu_del_vm_change_state_handler(pfl->vmstate); + pfl->vmstate = NULL; + + DPRINTF("%s: updating bdrv for %s\n", __func__, pfl->name); + pflash_update(pfl, 0, pfl->sector_len * pfl->nb_blocs); +} + static int pflash_post_load(void *opaque, int version_id) { pflash_t *pfl = opaque; if (!pfl->ro) { - DPRINTF("%s: updating bdrv for %s\n", __func__, pfl->name); - pflash_update(pfl, 0, pfl->sector_len * pfl->nb_blocs); + pfl->vmstate = qemu_add_vm_change_state_handler(postload_update_cb, + pfl); } return 0; } diff --git a/nbd/client.c b/nbd/client.c index 6777e589d1228585d283210c0d7e6c46ae270d65..48f2a21f3387ee72bd01c9932c2cfa7c867f8c87 100644 --- a/nbd/client.c +++ b/nbd/client.c @@ -192,13 +192,18 @@ static int nbd_receive_list(QIOChannel *ioc, char **name, Error **errp) return -1; } } else if (type == NBD_REP_SERVER) { + if (len < sizeof(namelen) || len > NBD_MAX_BUFFER_SIZE) { + error_setg(errp, "incorrect option length"); + return -1; + } if (read_sync(ioc, &namelen, sizeof(namelen)) != sizeof(namelen)) { error_setg(errp, "failed to read option name length"); return -1; } namelen = be32_to_cpu(namelen); - if (len != (namelen + sizeof(namelen))) { - error_setg(errp, "incorrect option mame length"); + len -= sizeof(namelen); + if (len < namelen) { + error_setg(errp, "incorrect option name length"); return -1; } if (namelen > 255) { @@ -214,6 +219,20 @@ static int nbd_receive_list(QIOChannel *ioc, char **name, Error **errp) return -1; } (*name)[namelen] = '\0'; + len -= namelen; + if (len) { + char *buf = g_malloc(len + 1); + if (read_sync(ioc, buf, len) != len) { + error_setg(errp, "failed to read export description"); + g_free(*name); + g_free(buf); + *name = NULL; + return -1; + } + buf[len] = '\0'; + TRACE("Ignoring export description: %s", buf); + g_free(buf); + } } else { error_setg(errp, "Unexpected reply type %x expected %x", type, NBD_REP_SERVER); diff --git a/nbd/server.c b/nbd/server.c index 2a4dd10f52c6e058b339f6ee397a683a40c7b03d..a13a69169aa74cb603189d5c1237e4032bdfa49c 100644 --- a/nbd/server.c +++ b/nbd/server.c @@ -449,11 +449,19 @@ static int nbd_negotiate_options(NBDClient *client) client->ioc = QIO_CHANNEL(tioc); break; + case NBD_OPT_EXPORT_NAME: + /* No way to return an error to client, so drop connection */ + TRACE("Option 0x%x not permitted before TLS", clientflags); + return -EINVAL; + default: TRACE("Option 0x%x not permitted before TLS", clientflags); + if (nbd_negotiate_drop_sync(client->ioc, length) != length) { + return -EIO; + } nbd_negotiate_send_rep(client->ioc, NBD_REP_ERR_TLS_REQD, clientflags); - return -EINVAL; + break; } } else if (fixedNewstyle) { switch (clientflags) { @@ -471,6 +479,9 @@ static int nbd_negotiate_options(NBDClient *client) return nbd_negotiate_handle_export_name(client, length); case NBD_OPT_STARTTLS: + if (nbd_negotiate_drop_sync(client->ioc, length) != length) { + return -EIO; + } if (client->tlscreds) { TRACE("TLS already enabled"); nbd_negotiate_send_rep(client->ioc, NBD_REP_ERR_INVALID, @@ -480,7 +491,7 @@ static int nbd_negotiate_options(NBDClient *client) nbd_negotiate_send_rep(client->ioc, NBD_REP_ERR_POLICY, clientflags); } - return -EINVAL; + break; default: TRACE("Unsupported option 0x%x", clientflags); if (nbd_negotiate_drop_sync(client->ioc, length) != length) { diff --git a/qemu-io-cmds.c b/qemu-io-cmds.c index 382faa8a2a1768efbd54529cdfbb48683c6d70e9..e34f7771182146de192936fe18b44f79f65804e4 100644 --- a/qemu-io-cmds.c +++ b/qemu-io-cmds.c @@ -1416,6 +1416,7 @@ struct aio_ctx { int vflag; int Cflag; int Pflag; + int zflag; BlockAcctCookie acct; int pattern; struct timeval t1; @@ -1446,8 +1447,10 @@ static void aio_write_done(void *opaque, int ret) print_report("wrote", &t2, ctx->offset, ctx->qiov.size, ctx->qiov.size, 1, ctx->Cflag); out: - qemu_io_free(ctx->buf); - qemu_iovec_destroy(&ctx->qiov); + if (!ctx->zflag) { + qemu_io_free(ctx->buf); + qemu_iovec_destroy(&ctx->qiov); + } g_free(ctx); } @@ -1612,6 +1615,7 @@ static void aio_write_help(void) " -P, -- use different pattern to fill file\n" " -C, -- report statistics in a machine parsable format\n" " -q, -- quiet mode, do not show I/O statistics\n" +" -z, -- write zeroes using blk_aio_write_zeroes\n" "\n"); } @@ -1622,7 +1626,7 @@ static const cmdinfo_t aio_write_cmd = { .cfunc = aio_write_f, .argmin = 2, .argmax = -1, - .args = "[-Cq] [-P pattern ] off len [len..]", + .args = "[-Cqz] [-P pattern ] off len [len..]", .oneline = "asynchronously writes a number of bytes", .help = aio_write_help, }; @@ -1634,7 +1638,7 @@ static int aio_write_f(BlockBackend *blk, int argc, char **argv) struct aio_ctx *ctx = g_new0(struct aio_ctx, 1); ctx->blk = blk; - while ((c = getopt(argc, argv, "CqP:")) != -1) { + while ((c = getopt(argc, argv, "CqP:z")) != -1) { switch (c) { case 'C': ctx->Cflag = 1; @@ -1649,6 +1653,9 @@ static int aio_write_f(BlockBackend *blk, int argc, char **argv) return 0; } break; + case 'z': + ctx->zflag = 1; + break; default: g_free(ctx); return qemuio_command_usage(&aio_write_cmd); @@ -1660,6 +1667,18 @@ static int aio_write_f(BlockBackend *blk, int argc, char **argv) return qemuio_command_usage(&aio_write_cmd); } + if (ctx->zflag && optind != argc - 2) { + printf("-z supports only a single length parameter\n"); + g_free(ctx); + return 0; + } + + if (ctx->zflag && ctx->Pflag) { + printf("-z and -P cannot be specified at the same time\n"); + g_free(ctx); + return 0; + } + ctx->offset = cvtnum(argv[optind]); if (ctx->offset < 0) { print_cvtnum_err(ctx->offset, argv[optind]); @@ -1676,19 +1695,33 @@ static int aio_write_f(BlockBackend *blk, int argc, char **argv) return 0; } - nr_iov = argc - optind; - ctx->buf = create_iovec(blk, &ctx->qiov, &argv[optind], nr_iov, pattern); - if (ctx->buf == NULL) { - block_acct_invalid(blk_get_stats(blk), BLOCK_ACCT_WRITE); - g_free(ctx); - return 0; - } + if (ctx->zflag) { + int64_t count = cvtnum(argv[optind]); + if (count < 0) { + print_cvtnum_err(count, argv[optind]); + return 0; + } - gettimeofday(&ctx->t1, NULL); - block_acct_start(blk_get_stats(blk), &ctx->acct, ctx->qiov.size, - BLOCK_ACCT_WRITE); - blk_aio_writev(blk, ctx->offset >> 9, &ctx->qiov, - ctx->qiov.size >> 9, aio_write_done, ctx); + ctx->qiov.size = count; + blk_aio_write_zeroes(blk, ctx->offset >> 9, count >> 9, 0, + aio_write_done, ctx); + } else { + nr_iov = argc - optind; + ctx->buf = create_iovec(blk, &ctx->qiov, &argv[optind], nr_iov, + pattern); + if (ctx->buf == NULL) { + block_acct_invalid(blk_get_stats(blk), BLOCK_ACCT_WRITE); + g_free(ctx); + return 0; + } + + gettimeofday(&ctx->t1, NULL); + block_acct_start(blk_get_stats(blk), &ctx->acct, ctx->qiov.size, + BLOCK_ACCT_WRITE); + + blk_aio_writev(blk, ctx->offset >> 9, &ctx->qiov, + ctx->qiov.size >> 9, aio_write_done, ctx); + } return 0; } diff --git a/qemu-nbd.c b/qemu-nbd.c index b5751f853b203c6170daa2cfd68c96b808e8f73c..2c9754e5d687fce447dd0e4db7b247c80c7fa3f2 100644 --- a/qemu-nbd.c +++ b/qemu-nbd.c @@ -215,7 +215,7 @@ static int find_partition(BlockBackend *blk, int partition, static void termsig_handler(int signum) { - state = TERMINATE; + atomic_cmpxchg(&state, RUNNING, TERMINATE); qemu_notify_event(); } diff --git a/tests/qemu-iotests/001 b/tests/qemu-iotests/001 index 4e1646941b3bfe31a6b83afe9e4ec7085967c833..ffd14e2ce96f8ea11005c1d2046071235f462c86 100755 --- a/tests/qemu-iotests/001 +++ b/tests/qemu-iotests/001 @@ -25,7 +25,6 @@ seq=`basename $0` echo "QA output created by $seq" here=`pwd` -tmp=/tmp/$$ status=1 # failure is the default! _cleanup() diff --git a/tests/qemu-iotests/002 b/tests/qemu-iotests/002 index 6a865aac733c8df67549297bbefdab866221e8e6..d4f8e91b917d5ccfc3ef31c65b519ad387c1e7a0 100755 --- a/tests/qemu-iotests/002 +++ b/tests/qemu-iotests/002 @@ -25,7 +25,6 @@ seq=`basename $0` echo "QA output created by $seq" here=`pwd` -tmp=/tmp/$$ status=1 # failure is the default! _cleanup() diff --git a/tests/qemu-iotests/003 b/tests/qemu-iotests/003 index 98638d4ce72f48bef52f6e9cbc06257c995a91b6..19889b9fcdba2293107918101d71aec0dccaf147 100755 --- a/tests/qemu-iotests/003 +++ b/tests/qemu-iotests/003 @@ -25,7 +25,6 @@ seq=`basename $0` echo "QA output created by $seq" here=`pwd` -tmp=/tmp/$$ status=1 # failure is the default! _cleanup() diff --git a/tests/qemu-iotests/004 b/tests/qemu-iotests/004 index 2ad77ed51410ffc6ef3cae9e2d4367f1acfba6a1..67e1beb209b4999136a13d4aae57bdaddad737d0 100755 --- a/tests/qemu-iotests/004 +++ b/tests/qemu-iotests/004 @@ -25,7 +25,6 @@ seq=`basename $0` echo "QA output created by $seq" here=`pwd` -tmp=/tmp/$$ status=1 # failure is the default! _cleanup() diff --git a/tests/qemu-iotests/005 b/tests/qemu-iotests/005 index ba1236dfbfaaadca4cb39d860c23a69d67b8de34..444737751ffbf229b20795bd0c64edf88e8f5331 100755 --- a/tests/qemu-iotests/005 +++ b/tests/qemu-iotests/005 @@ -28,7 +28,6 @@ seq=`basename $0` echo "QA output created by $seq" here=`pwd` -tmp=/tmp/$$ status=1 # failure is the default! _cleanup() diff --git a/tests/qemu-iotests/007 b/tests/qemu-iotests/007 index 7b5aff59b28242de1c9db46caf6fc93679f973a6..fa543eeb7db70f51843280e79ae61bd0902840b1 100755 --- a/tests/qemu-iotests/007 +++ b/tests/qemu-iotests/007 @@ -25,7 +25,6 @@ seq=`basename $0` echo "QA output created by $seq" here=`pwd` -tmp=/tmp/$$ status=1 # failure is the default! _cleanup() diff --git a/tests/qemu-iotests/008 b/tests/qemu-iotests/008 index 2d28efd42866f3d028fe76492d11ed3c8f0c68c2..8e89d74fe9b36bd5cbbe1a2c6b2093d869a2cc8a 100755 --- a/tests/qemu-iotests/008 +++ b/tests/qemu-iotests/008 @@ -25,7 +25,6 @@ seq=`basename $0` echo "QA output created by $seq" here=`pwd` -tmp=/tmp/$$ status=1 # failure is the default! _cleanup() diff --git a/tests/qemu-iotests/009 b/tests/qemu-iotests/009 index 57a43f5a16ac59bcd4da81ea6659b2022b70ae1a..16e4475ca4bd037684e09eaf37bf27f03bd245bb 100755 --- a/tests/qemu-iotests/009 +++ b/tests/qemu-iotests/009 @@ -25,7 +25,6 @@ seq=`basename $0` echo "QA output created by $seq" here=`pwd` -tmp=/tmp/$$ status=1 # failure is the default! _cleanup() diff --git a/tests/qemu-iotests/010 b/tests/qemu-iotests/010 index 896a0058ff2a6ff565df8a1f93e39e9f80f69e8a..151dac238d5e74dee93333e5557a656ef29bc365 100755 --- a/tests/qemu-iotests/010 +++ b/tests/qemu-iotests/010 @@ -25,7 +25,6 @@ seq=`basename $0` echo "QA output created by $seq" here=`pwd` -tmp=/tmp/$$ status=1 # failure is the default! _cleanup() diff --git a/tests/qemu-iotests/011 b/tests/qemu-iotests/011 index 1c5158af43509c6a41b1957a9f5d987e55b6e0ac..f8d044ec8577ba1bd202b7f3e4bdce76ff1b3a1d 100755 --- a/tests/qemu-iotests/011 +++ b/tests/qemu-iotests/011 @@ -25,7 +25,6 @@ seq=`basename $0` echo "QA output created by $seq" here=`pwd` -tmp=/tmp/$$ status=1 # failure is the default! _cleanup() diff --git a/tests/qemu-iotests/012 b/tests/qemu-iotests/012 index 7c5b6892d34704e80856abf89bbcf78c6c2278c0..d1d3f22093432f99f346ac80c2a6d81b19eef235 100755 --- a/tests/qemu-iotests/012 +++ b/tests/qemu-iotests/012 @@ -27,7 +27,6 @@ seq=`basename $0` echo "QA output created by $seq" here=`pwd` -tmp=/tmp/$$ status=1 # failure is the default! _cleanup() diff --git a/tests/qemu-iotests/013 b/tests/qemu-iotests/013 index ea3cab91d6272ffc09d25f816dbe8d664be6a43f..d013f87da995fdad458e201a9184d9cd3c3e3f82 100755 --- a/tests/qemu-iotests/013 +++ b/tests/qemu-iotests/013 @@ -25,7 +25,6 @@ seq=`basename $0` echo "QA output created by $seq" here=`pwd` -tmp=/tmp/$$ status=1 # failure is the default! _cleanup() diff --git a/tests/qemu-iotests/014 b/tests/qemu-iotests/014 index b23c2db9b6e3bd1bcc3e9a639cd699665c62137c..2ea79e8c8b7ae376d84d6e525d6a2f25efe27128 100755 --- a/tests/qemu-iotests/014 +++ b/tests/qemu-iotests/014 @@ -27,7 +27,6 @@ seq=`basename $0` echo "QA output created by $seq" here=`pwd` -tmp=/tmp/$$ status=1 # failure is the default! _cleanup() diff --git a/tests/qemu-iotests/015 b/tests/qemu-iotests/015 index 6f26095243679b3fbe2aba9ac3f6ebb975eb7f0f..aaf9c3f41501272efcc6288b57c9cb598da22531 100755 --- a/tests/qemu-iotests/015 +++ b/tests/qemu-iotests/015 @@ -25,7 +25,6 @@ seq=`basename $0` echo "QA output created by $seq" here=`pwd` -tmp=/tmp/$$ status=1 # failure is the default! _cleanup() diff --git a/tests/qemu-iotests/017 b/tests/qemu-iotests/017 index 3af3cdfbc33ca39d32da71d31b0456a736bb2bd7..e3f9e7596744e0c9f0c49d2b4c0663d74d881e01 100755 --- a/tests/qemu-iotests/017 +++ b/tests/qemu-iotests/017 @@ -25,7 +25,6 @@ seq=`basename $0` echo "QA output created by $seq" here=`pwd` -tmp=/tmp/$$ status=1 # failure is the default! _cleanup() diff --git a/tests/qemu-iotests/018 b/tests/qemu-iotests/018 index 07b2de970eb4f139be74465d9a403f1b1afe4f61..1d39d35c4792868d653e971e4e13ded17c976747 100755 --- a/tests/qemu-iotests/018 +++ b/tests/qemu-iotests/018 @@ -25,7 +25,6 @@ seq=`basename $0` echo "QA output created by $seq" here=`pwd` -tmp=/tmp/$$ status=1 # failure is the default! _cleanup() diff --git a/tests/qemu-iotests/019 b/tests/qemu-iotests/019 index 0937b5c57d0e3a53a669f8369b683aebadf8bb14..24a789a25c0dfda02f4c4a96a8f309064554d6df 100755 --- a/tests/qemu-iotests/019 +++ b/tests/qemu-iotests/019 @@ -27,7 +27,6 @@ seq=`basename $0` echo "QA output created by $seq" here=`pwd` -tmp=/tmp/$$ status=1 # failure is the default! _cleanup() diff --git a/tests/qemu-iotests/020 b/tests/qemu-iotests/020 index 6625b553baaa669eafbabc17bd184ba9c91796db..9c4a68c977a6b6890666950a8805324236155563 100755 --- a/tests/qemu-iotests/020 +++ b/tests/qemu-iotests/020 @@ -25,7 +25,6 @@ seq=`basename $0` echo "QA output created by $seq" here=`pwd` -tmp=/tmp/$$ status=1 # failure is the default! _cleanup() diff --git a/tests/qemu-iotests/021 b/tests/qemu-iotests/021 index 1c69024ccb844f5befb747e3f94a86daee0a1d73..11e8ed7187f7879011f5fac01676eff3cab09584 100755 --- a/tests/qemu-iotests/021 +++ b/tests/qemu-iotests/021 @@ -25,7 +25,6 @@ seq=`basename $0` echo "QA output created by $seq" here=`pwd` -tmp=/tmp/$$ status=1 # failure is the default! _cleanup() diff --git a/tests/qemu-iotests/022 b/tests/qemu-iotests/022 index d35b8162be0fcd77825c10b54f7c9ff864fc46c1..2452a9f86a0bf3d13504658a0b1d422eba43043c 100755 --- a/tests/qemu-iotests/022 +++ b/tests/qemu-iotests/022 @@ -27,7 +27,6 @@ seq=`basename $0` echo "QA output created by $seq" here=`pwd` -tmp=/tmp/$$ status=1 # failure is the default! _cleanup() diff --git a/tests/qemu-iotests/023 b/tests/qemu-iotests/023 index 9ad06b990e2ca7c4f12ba3d4251aee47b3a4706f..497ae1ed17c322ad5f64ced77713c7ccffaa17ab 100755 --- a/tests/qemu-iotests/023 +++ b/tests/qemu-iotests/023 @@ -25,7 +25,6 @@ seq=`basename $0` echo "QA output created by $seq" here=`pwd` -tmp=/tmp/$$ status=1 # failure is the default! _cleanup() diff --git a/tests/qemu-iotests/024 b/tests/qemu-iotests/024 index 2c2d14846d83ef076ccbd4abf769e3dfcae361d0..e0d77ce2f5c64b8e3b6013136f8b32c71473e85c 100755 --- a/tests/qemu-iotests/024 +++ b/tests/qemu-iotests/024 @@ -25,7 +25,6 @@ seq=`basename $0` echo "QA output created by $seq" here=`pwd` -tmp=/tmp/$$ status=1 # failure is the default! _cleanup() diff --git a/tests/qemu-iotests/025 b/tests/qemu-iotests/025 index 467a4b7090a9007ce6b46e57a02ff2adf92a7533..c41370f3b2df0a927db8ce799e4e34f860a5c844 100755 --- a/tests/qemu-iotests/025 +++ b/tests/qemu-iotests/025 @@ -25,7 +25,6 @@ seq=`basename $0` echo "QA output created by $seq" here=`pwd` -tmp=/tmp/$$ status=1 # failure is the default! _cleanup() diff --git a/tests/qemu-iotests/026 b/tests/qemu-iotests/026 index ba1047c96a41ddc82aece7b27669320ca852a47c..f5a7f02b25f398a3beca430b0d60fef6006e6a0f 100755 --- a/tests/qemu-iotests/026 +++ b/tests/qemu-iotests/026 @@ -25,7 +25,6 @@ seq=`basename $0` echo "QA output created by $seq" here=`pwd` -tmp=/tmp/$$ status=1 # failure is the default! _cleanup() diff --git a/tests/qemu-iotests/027 b/tests/qemu-iotests/027 index 3fa81b83bbc7580ebac9de27fc3576f24e006cfa..08593da77579ac6d973215f077679d8c4d9ac71e 100755 --- a/tests/qemu-iotests/027 +++ b/tests/qemu-iotests/027 @@ -25,7 +25,6 @@ seq=`basename $0` echo "QA output created by $seq" here=`pwd` -tmp=/tmp/$$ status=1 # failure is the default! _cleanup() diff --git a/tests/qemu-iotests/028 b/tests/qemu-iotests/028 index 4909b9bc8809c0edd63025089e16fee0afd3a2c2..7783e57c716c751a33eab81061d74d6574022aaa 100755 --- a/tests/qemu-iotests/028 +++ b/tests/qemu-iotests/028 @@ -28,7 +28,6 @@ seq=`basename $0` echo "QA output created by $seq" here=`pwd` -tmp=/tmp/$$ status=1 # failure is the default! _cleanup() diff --git a/tests/qemu-iotests/029 b/tests/qemu-iotests/029 index b9cd826c7ee5ed2180f1d6c90323ad98c7a8e6b4..e639ac0ddffe792ff0bf143228eaebafc3d75a24 100755 --- a/tests/qemu-iotests/029 +++ b/tests/qemu-iotests/029 @@ -25,7 +25,6 @@ seq=`basename $0` echo "QA output created by $seq" here=`pwd` -tmp=/tmp/$$ status=1 # failure is the default! _cleanup() diff --git a/tests/qemu-iotests/031 b/tests/qemu-iotests/031 index 2a77ba8cbb00d316bfd52baabe8a0e3876125ed4..1e08abc5ed132baa56e0f38ea9a374444c8092eb 100755 --- a/tests/qemu-iotests/031 +++ b/tests/qemu-iotests/031 @@ -25,7 +25,6 @@ seq=`basename $0` echo "QA output created by $seq" here=`pwd` -tmp=/tmp/$$ status=1 # failure is the default! _cleanup() diff --git a/tests/qemu-iotests/032 b/tests/qemu-iotests/032 index b1ba5c3218267a53effd3de635925478866ce30d..24bcb52fc2d04392e478b9b27a5984edd8361b58 100755 --- a/tests/qemu-iotests/032 +++ b/tests/qemu-iotests/032 @@ -27,7 +27,6 @@ seq=`basename $0` echo "QA output created by $seq" here=`pwd` -tmp=/tmp/$$ status=1 # failure is the default! _cleanup() diff --git a/tests/qemu-iotests/033 b/tests/qemu-iotests/033 index a61d8ced1ce7a12cba1f52dee6f48415dc25759a..16edcf2f00c01fb6a71944e1f9d55c4264e81964 100755 --- a/tests/qemu-iotests/033 +++ b/tests/qemu-iotests/033 @@ -25,7 +25,6 @@ seq=`basename $0` echo "QA output created by $seq" here=`pwd` -tmp=/tmp/$$ status=1 # failure is the default! _cleanup() @@ -57,12 +56,13 @@ do_test() } | $QEMU_IO } +for write_zero_cmd in "write -z" "aio_write -z"; do for align in 512 4k; do echo echo "== preparing image ==" do_test $align "write -P 0xa 0x200 0x400" "$TEST_IMG" | _filter_qemu_io do_test $align "write -P 0xa 0x20000 0x600" "$TEST_IMG" | _filter_qemu_io - do_test $align "write -z 0x400 0x20000" "$TEST_IMG" | _filter_qemu_io + do_test $align "$write_zero_cmd 0x400 0x20000" "$TEST_IMG" | _filter_qemu_io echo echo "== verifying patterns (1) ==" @@ -73,7 +73,7 @@ for align in 512 4k; do echo echo "== rewriting zeroes ==" do_test $align "write -P 0xb 0x10000 0x10000" "$TEST_IMG" | _filter_qemu_io - do_test $align "write -z 0x10000 0x10000" "$TEST_IMG" | _filter_qemu_io + do_test $align "$write_zero_cmd 0x10000 0x10000" "$TEST_IMG" | _filter_qemu_io echo echo "== verifying patterns (2) ==" @@ -82,7 +82,7 @@ for align in 512 4k; do echo echo "== rewriting unaligned zeroes ==" do_test $align "write -P 0xb 0x0 0x1000" "$TEST_IMG" | _filter_qemu_io - do_test $align "write -z 0x200 0x200" "$TEST_IMG" | _filter_qemu_io + do_test $align "$write_zero_cmd 0x200 0x200" "$TEST_IMG" | _filter_qemu_io echo echo "== verifying patterns (3) ==" @@ -92,6 +92,7 @@ for align in 512 4k; do echo done +done # success, all done echo "*** done" diff --git a/tests/qemu-iotests/033.out b/tests/qemu-iotests/033.out index c3d18aa45073a148536e5f28501e6a22aff2cf1b..95929eff703fe076c465e163acfd20c81e24bd04 100644 --- a/tests/qemu-iotests/033.out +++ b/tests/qemu-iotests/033.out @@ -42,6 +42,88 @@ read 3072/3072 bytes at offset 1024 3 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) +== preparing image == +wrote 1024/1024 bytes at offset 512 +1 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) +wrote 1536/1536 bytes at offset 131072 +1.500 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) +wrote 131072/131072 bytes at offset 1024 +128 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) + +== verifying patterns (1) == +read 512/512 bytes at offset 512 +512 bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) +read 131072/131072 bytes at offset 1024 +128 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) +read 512/512 bytes at offset 132096 +512 bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) + +== rewriting zeroes == +wrote 65536/65536 bytes at offset 65536 +64 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) +wrote 65536/65536 bytes at offset 65536 +64 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) + +== verifying patterns (2) == +read 131072/131072 bytes at offset 1024 +128 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) + +== rewriting unaligned zeroes == +wrote 4096/4096 bytes at offset 0 +4 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) +wrote 512/512 bytes at offset 512 +512 bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) + +== verifying patterns (3) == +read 512/512 bytes at offset 0 +512 bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) +read 512/512 bytes at offset 512 +512 bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) +read 3072/3072 bytes at offset 1024 +3 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) + + +== preparing image == +wrote 1024/1024 bytes at offset 512 +1 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) +wrote 1536/1536 bytes at offset 131072 +1.500 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) +wrote 131072/131072 bytes at offset 1024 +128 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) + +== verifying patterns (1) == +read 512/512 bytes at offset 512 +512 bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) +read 131072/131072 bytes at offset 1024 +128 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) +read 512/512 bytes at offset 132096 +512 bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) + +== rewriting zeroes == +wrote 65536/65536 bytes at offset 65536 +64 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) +wrote 65536/65536 bytes at offset 65536 +64 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) + +== verifying patterns (2) == +read 131072/131072 bytes at offset 1024 +128 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) + +== rewriting unaligned zeroes == +wrote 4096/4096 bytes at offset 0 +4 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) +wrote 512/512 bytes at offset 512 +512 bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) + +== verifying patterns (3) == +read 512/512 bytes at offset 0 +512 bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) +read 512/512 bytes at offset 512 +512 bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) +read 3072/3072 bytes at offset 1024 +3 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) + + == preparing image == wrote 1024/1024 bytes at offset 512 1 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) diff --git a/tests/qemu-iotests/034 b/tests/qemu-iotests/034 index c769dd8b863db15f5c03b8b2f308ac6ffc7fe4c3..c711cfce94548f29ed451d114bcd36b3a6e1a7d5 100755 --- a/tests/qemu-iotests/034 +++ b/tests/qemu-iotests/034 @@ -25,7 +25,6 @@ seq=`basename $0` echo "QA output created by $seq" here=`pwd` -tmp=/tmp/$$ status=1 # failure is the default! _cleanup() diff --git a/tests/qemu-iotests/035 b/tests/qemu-iotests/035 index ebe9b8c9258339dfcd73dc2618c61d9284f8d663..efc38e4d49d2e708327dc84a708c98f5c7922d0a 100755 --- a/tests/qemu-iotests/035 +++ b/tests/qemu-iotests/035 @@ -26,7 +26,6 @@ seq=`basename $0` echo "QA output created by $seq" here=`pwd` -tmp=/tmp/$$ status=1 # failure is the default! _cleanup() diff --git a/tests/qemu-iotests/036 b/tests/qemu-iotests/036 index c4cc91b8af57241556a1184452f05105262d77e4..ce638d607622f9d98998017588e52f0fa44e3cf3 100755 --- a/tests/qemu-iotests/036 +++ b/tests/qemu-iotests/036 @@ -28,7 +28,6 @@ seq=`basename $0` echo "QA output created by $seq" here=`pwd` -tmp=/tmp/$$ status=1 # failure is the default! _cleanup() diff --git a/tests/qemu-iotests/037 b/tests/qemu-iotests/037 index 586245159fa9a3417e21aa919c14ee6f73eb8b82..c476b823d2b7b08dc8ec2c7b72515339ad85a0d1 100755 --- a/tests/qemu-iotests/037 +++ b/tests/qemu-iotests/037 @@ -25,7 +25,6 @@ seq=`basename $0` echo "QA output created by $seq" here=`pwd` -tmp=/tmp/$$ status=1 # failure is the default! _cleanup() diff --git a/tests/qemu-iotests/038 b/tests/qemu-iotests/038 index 34fe698117a427ec0c0d98613af98a0e6d691eb8..d99a1501d7a499e9b2bf5c49d8b9147403389ce9 100755 --- a/tests/qemu-iotests/038 +++ b/tests/qemu-iotests/038 @@ -25,7 +25,6 @@ seq=`basename $0` echo "QA output created by $seq" here=`pwd` -tmp=/tmp/$$ status=1 # failure is the default! _cleanup() diff --git a/tests/qemu-iotests/039 b/tests/qemu-iotests/039 index 9e9b379baa986640205b9285c7abee1b9baef7b1..1f48339692d244af9d9e803161c224140757bb1a 100755 --- a/tests/qemu-iotests/039 +++ b/tests/qemu-iotests/039 @@ -28,7 +28,6 @@ seq=`basename $0` echo "QA output created by $seq" here=`pwd` -tmp=/tmp/$$ status=1 # failure is the default! _cleanup() diff --git a/tests/qemu-iotests/041 b/tests/qemu-iotests/041 index c7da95d94e7dcfdec337f0b99adc7845783c0889..b1c542f99b271a36e598a7e3cc7fcfe63741a7fb 100755 --- a/tests/qemu-iotests/041 +++ b/tests/qemu-iotests/041 @@ -810,8 +810,7 @@ class TestRepairQuorum(iotests.QMPTestCase): self.assert_qmp(result, 'return', {}) self.complete_and_wait(drive="quorum0") - result = self.vm.qmp('query-named-block-nodes') - self.assert_qmp(result, 'return[0]/file', quorum_repair_img) + self.assert_has_block_node("repair0", quorum_repair_img) # TODO: a better test requiring some QEMU infrastructure will be added # to check that this file is really driven by quorum self.vm.shutdown() @@ -833,8 +832,7 @@ class TestRepairQuorum(iotests.QMPTestCase): self.cancel_and_wait(drive="quorum0", force=True) # here we check that the last registered quorum file has not been # swapped out and unref - result = self.vm.qmp('query-named-block-nodes') - self.assert_qmp(result, 'return[1]/file', quorum_img3) + self.assert_has_block_node(None, quorum_img3) self.vm.shutdown() def test_cancel_after_ready(self): @@ -850,10 +848,9 @@ class TestRepairQuorum(iotests.QMPTestCase): self.assert_qmp(result, 'return', {}) self.wait_ready_and_cancel(drive="quorum0") - result = self.vm.qmp('query-named-block-nodes') # here we check that the last registered quorum file has not been # swapped out and unref - self.assert_qmp(result, 'return[1]/file', quorum_img3) + self.assert_has_block_node(None, quorum_img3) self.vm.shutdown() self.assertTrue(iotests.compare_images(quorum_img2, quorum_repair_img), 'target image does not match source after mirroring') @@ -974,8 +971,7 @@ class TestRepairQuorum(iotests.QMPTestCase): self.assert_qmp(result, 'return', {}) self.complete_and_wait(drive="quorum0") - result = self.vm.qmp('query-named-block-nodes') - self.assert_qmp(result, 'return[0]/file', quorum_repair_img) + self.assert_has_block_node("repair0", quorum_repair_img) # TODO: a better test requiring some QEMU infrastructure will be added # to check that this file is really driven by quorum self.vm.shutdown() diff --git a/tests/qemu-iotests/042 b/tests/qemu-iotests/042 index 94ce3a9cc39e419dcd9e0ffc8535a6714b360877..351b2830a2974e09ea25c3b7e34cd91ae5afe044 100755 --- a/tests/qemu-iotests/042 +++ b/tests/qemu-iotests/042 @@ -25,7 +25,6 @@ seq=`basename $0` echo "QA output created by $seq" here=`pwd` -tmp=/tmp/$$ status=1 # failure is the default! _cleanup() diff --git a/tests/qemu-iotests/043 b/tests/qemu-iotests/043 index b316b97c0c87bc27a578ff3ef0c53e5025fd1de5..1c6c22d92a8e53b8bc35a00ccd3797393afb0105 100755 --- a/tests/qemu-iotests/043 +++ b/tests/qemu-iotests/043 @@ -25,7 +25,6 @@ seq=`basename $0` echo "QA output created by $seq" here=`pwd` -tmp=/tmp/$$ status=1 # failure is the default! _cleanup() diff --git a/tests/qemu-iotests/046 b/tests/qemu-iotests/046 index e0be46cf2be19fe544e0d9b1b5570d8d8fe7096e..e528b67cc62fca2b9bf64d898dcc259608a564dc 100755 --- a/tests/qemu-iotests/046 +++ b/tests/qemu-iotests/046 @@ -25,7 +25,6 @@ seq=`basename $0` echo "QA output created by $seq" here=`pwd` -tmp=/tmp/$$ status=1 # failure is the default! _cleanup() diff --git a/tests/qemu-iotests/047 b/tests/qemu-iotests/047 index c35cd096b8831a63787ceea418baef39653e592b..1b8f3d4a64e92f4bc3c9637285fc0e18739a1b2d 100755 --- a/tests/qemu-iotests/047 +++ b/tests/qemu-iotests/047 @@ -26,7 +26,6 @@ seq=`basename $0` echo "QA output created by $seq" here=`pwd` -tmp=/tmp/$$ status=1 # failure is the default! _cleanup() diff --git a/tests/qemu-iotests/049 b/tests/qemu-iotests/049 index 93aa0ea55fa8026697d37fd791f9b949aa8c5256..fff07604fced4c1ef7d10dcbc93adfafa5aa0bca 100755 --- a/tests/qemu-iotests/049 +++ b/tests/qemu-iotests/049 @@ -25,7 +25,6 @@ seq=`basename $0` echo "QA output created by $seq" here=`pwd` -tmp=/tmp/$$ status=1 # failure is the default! _cleanup() diff --git a/tests/qemu-iotests/050 b/tests/qemu-iotests/050 index 13006dd1db82fc6086c393c276f275ddf38b7c98..03b4a5d6208f9efab8ad09eff00823dcc0c7bbb2 100755 --- a/tests/qemu-iotests/050 +++ b/tests/qemu-iotests/050 @@ -25,7 +25,6 @@ seq=`basename $0` echo "QA output created by $seq" here=`pwd` -tmp=/tmp/$$ status=1 # failure is the default! _cleanup() diff --git a/tests/qemu-iotests/051 b/tests/qemu-iotests/051 index 88b3d91da800681d63822a4eef7aa11835335db6..630cb7a114fb467f1c398fb2cdc35ace071a6f15 100755 --- a/tests/qemu-iotests/051 +++ b/tests/qemu-iotests/051 @@ -25,7 +25,6 @@ seq=`basename $0` echo "QA output created by $seq" here=`pwd` -tmp=/tmp/$$ status=1 # failure is the default! _cleanup() diff --git a/tests/qemu-iotests/052 b/tests/qemu-iotests/052 index 61959e286eaf1fd229a4feb5fc7d1dd2c6a9b056..4b647242d2d1cce5ffea192fc216e3051da50b67 100755 --- a/tests/qemu-iotests/052 +++ b/tests/qemu-iotests/052 @@ -25,7 +25,6 @@ seq=`basename $0` echo "QA output created by $seq" here=`pwd` -tmp=/tmp/$$ status=1 # failure is the default! _cleanup() diff --git a/tests/qemu-iotests/053 b/tests/qemu-iotests/053 index e589e5f1262affae8ea5c606fa6c347846221569..2a04f5f5516d96a72c35e0ecfb2251e624f386a8 100755 --- a/tests/qemu-iotests/053 +++ b/tests/qemu-iotests/053 @@ -25,7 +25,6 @@ seq=`basename $0` echo "QA output created by $seq" here=`pwd` -tmp=/tmp/$$ status=1 # failure is the default! _cleanup() diff --git a/tests/qemu-iotests/054 b/tests/qemu-iotests/054 index bd94153d66a5e894eeaca1a21616fcb66a8d8874..bf47ef9fac332aca84520a38f690b15e5626db45 100755 --- a/tests/qemu-iotests/054 +++ b/tests/qemu-iotests/054 @@ -25,7 +25,6 @@ seq=`basename $0` echo "QA output created by $seq" here=`pwd` -tmp=/tmp/$$ status=1 # failure is the default! _cleanup() diff --git a/tests/qemu-iotests/058 b/tests/qemu-iotests/058 index 63a6598784b95a66fab5f7704ebe1e5f4160665b..2253c6a6d15f1c0ef5372e0046e888369ae3776f 100755 --- a/tests/qemu-iotests/058 +++ b/tests/qemu-iotests/058 @@ -27,7 +27,6 @@ seq=`basename $0` echo "QA output created by $seq" here=`pwd` -tmp=/tmp/$$ status=1 # failure is the default! nbd_unix_socket=$TEST_DIR/test_qemu_nbd_socket diff --git a/tests/qemu-iotests/059 b/tests/qemu-iotests/059 index 0332bbb348fcf6ce704545d9f247b2ca72b4bed9..6655aaf3843a78f5c8d98433a5062e2d85075341 100755 --- a/tests/qemu-iotests/059 +++ b/tests/qemu-iotests/059 @@ -25,7 +25,6 @@ seq=`basename $0` echo "QA output created by $seq" here=`pwd` -tmp=/tmp/$$ status=1 # failure is the default! _cleanup() diff --git a/tests/qemu-iotests/060 b/tests/qemu-iotests/060 index c81319c169136c91916d927b6c39f7f0fa08305b..8e95c450eb2d30a375658fc7c7bc8485286c9948 100755 --- a/tests/qemu-iotests/060 +++ b/tests/qemu-iotests/060 @@ -25,7 +25,6 @@ seq="$(basename $0)" echo "QA output created by $seq" here="$PWD" -tmp=/tmp/$$ status=1 # failure is the default! _cleanup() diff --git a/tests/qemu-iotests/061 b/tests/qemu-iotests/061 index e191e65d5ff8f86f62b60efa8b55b9904a0bc17e..f5678b10c95d41b8d0cffb44d430ecade38d7336 100755 --- a/tests/qemu-iotests/061 +++ b/tests/qemu-iotests/061 @@ -25,7 +25,6 @@ seq=`basename $0` echo "QA output created by $seq" here=`pwd` -tmp=/tmp/$$ status=1 # failure is the default! _cleanup() diff --git a/tests/qemu-iotests/062 b/tests/qemu-iotests/062 index 0511246deeafacf881fc820f3a3e3132f386de68..051fb9f410074afc4547704e6c370afda8b455d9 100755 --- a/tests/qemu-iotests/062 +++ b/tests/qemu-iotests/062 @@ -26,7 +26,6 @@ seq=`basename $0` echo "QA output created by $seq" here=`pwd` -tmp=/tmp/$$ status=1 # failure is the default! _cleanup() diff --git a/tests/qemu-iotests/063 b/tests/qemu-iotests/063 index a47493a0766f3d403dc3316f83240c2d2b67eb6a..352e78c7785705598c84f15886aae8fc44396a58 100755 --- a/tests/qemu-iotests/063 +++ b/tests/qemu-iotests/063 @@ -26,7 +26,6 @@ seq=`basename $0` echo "QA output created by $seq" here=`pwd` -tmp=/tmp/$$ status=1 # failure is the default! _cleanup() diff --git a/tests/qemu-iotests/064 b/tests/qemu-iotests/064 index 7564563abde231e83618d0e71609d696479113f2..5792fbbc928906ca7e65528b9c14f495282eb780 100755 --- a/tests/qemu-iotests/064 +++ b/tests/qemu-iotests/064 @@ -25,7 +25,6 @@ seq=`basename $0` echo "QA output created by $seq" here=`pwd` -tmp=/tmp/$$ status=1 # failure is the default! _cleanup() diff --git a/tests/qemu-iotests/066 b/tests/qemu-iotests/066 index 1c2452b0c5bf24cb2487f201597dcdbeaa47bd7a..364166d3b25a04d60f01cab7d32887067abd48cf 100755 --- a/tests/qemu-iotests/066 +++ b/tests/qemu-iotests/066 @@ -25,7 +25,6 @@ seq="$(basename $0)" echo "QA output created by $seq" here="$PWD" -tmp=/tmp/$$ status=1 # failure is the default! _cleanup() diff --git a/tests/qemu-iotests/067 b/tests/qemu-iotests/067 index 77dec0d1fc88e76a37955ab70e781cc92d0951a7..c1df48eded52ea0d846a677a823767941aaa1c53 100755 --- a/tests/qemu-iotests/067 +++ b/tests/qemu-iotests/067 @@ -25,7 +25,6 @@ seq=`basename $0` echo "QA output created by $seq" here=`pwd` -tmp=/tmp/$$ status=1 # failure is the default! # get standard environment, filters and checks diff --git a/tests/qemu-iotests/068 b/tests/qemu-iotests/068 index 7562dd77eed320b52648f6e341cb0de97e98df42..68f6e825d95051270de9f26727dd4a8f6128865f 100755 --- a/tests/qemu-iotests/068 +++ b/tests/qemu-iotests/068 @@ -25,7 +25,6 @@ seq="$(basename $0)" echo "QA output created by $seq" here="$PWD" -tmp=/tmp/$$ status=1 # failure is the default! _cleanup() diff --git a/tests/qemu-iotests/069 b/tests/qemu-iotests/069 index ce9e0541b2b79dc9b628217cf72b3acb3b2c4ee3..96e55ef216092329489e83d8895e274864a4245e 100755 --- a/tests/qemu-iotests/069 +++ b/tests/qemu-iotests/069 @@ -25,7 +25,6 @@ seq="$(basename $0)" echo "QA output created by $seq" here="$PWD" -tmp=/tmp/$$ status=1 # failure is the default! _cleanup() diff --git a/tests/qemu-iotests/070 b/tests/qemu-iotests/070 index d649ddf9bd5938bcb293e4157bf15a0255005f94..8d08d74ff93707637a11da04d3f01e62ea465454 100755 --- a/tests/qemu-iotests/070 +++ b/tests/qemu-iotests/070 @@ -26,7 +26,6 @@ seq=`basename $0` echo "QA output created by $seq" here=`pwd` -tmp=/tmp/$$ status=1 # failure is the default! _cleanup() diff --git a/tests/qemu-iotests/071 b/tests/qemu-iotests/071 index 92ab991456c8330d1022a3ae1e90c0e5af65cf5f..bdfd91fef173142c61480ec8e87a9972e1cbb81e 100755 --- a/tests/qemu-iotests/071 +++ b/tests/qemu-iotests/071 @@ -25,7 +25,6 @@ seq="$(basename $0)" echo "QA output created by $seq" here="$PWD" -tmp=/tmp/$$ status=1 # failure is the default! _cleanup() diff --git a/tests/qemu-iotests/072 b/tests/qemu-iotests/072 index e4a723d7338aa8942c8cca97e6db9a01b78c4951..aa027c7d29336728e972cd6e62c9a044431eb2af 100755 --- a/tests/qemu-iotests/072 +++ b/tests/qemu-iotests/072 @@ -25,7 +25,6 @@ seq="$(basename $0)" echo "QA output created by $seq" here="$PWD" -tmp=/tmp/$$ status=1 # failure is the default! _cleanup() diff --git a/tests/qemu-iotests/073 b/tests/qemu-iotests/073 index 392db54999405bbf709548637fa7c2e2efef3ac4..ad37a617b2305d653ab9040a685604871d025301 100755 --- a/tests/qemu-iotests/073 +++ b/tests/qemu-iotests/073 @@ -25,7 +25,6 @@ seq=`basename $0` echo "QA output created by $seq" here=`pwd` -tmp=/tmp/$$ status=1 # failure is the default! _cleanup() diff --git a/tests/qemu-iotests/075 b/tests/qemu-iotests/075 index 6117660c58b1e8946f02322fd3671b49d9a5b1db..770d51c6cbde9d0b4c811687c36a0a473bf4b3ca 100755 --- a/tests/qemu-iotests/075 +++ b/tests/qemu-iotests/075 @@ -25,7 +25,6 @@ seq=`basename $0` echo "QA output created by $seq" here=`pwd` -tmp=/tmp/$$ status=1 # failure is the default! _cleanup() diff --git a/tests/qemu-iotests/076 b/tests/qemu-iotests/076 index c9b55a9801e5c05eeef3d572298a630ac0b54185..ef9e6a4ff32e6f96eefce71553e8d2592d500892 100755 --- a/tests/qemu-iotests/076 +++ b/tests/qemu-iotests/076 @@ -25,7 +25,6 @@ seq=`basename $0` echo "QA output created by $seq" here=`pwd` -tmp=/tmp/$$ status=1 # failure is the default! _cleanup() diff --git a/tests/qemu-iotests/077 b/tests/qemu-iotests/077 index 8a7223fa460f2223ac0372196e387d7c498692d1..4dc680b7fca336de39e4f6735fb0744e3c7ee12a 100755 --- a/tests/qemu-iotests/077 +++ b/tests/qemu-iotests/077 @@ -25,7 +25,6 @@ seq=`basename $0` echo "QA output created by $seq" here=`pwd` -tmp=/tmp/$$ status=1 # failure is the default! _cleanup() diff --git a/tests/qemu-iotests/078 b/tests/qemu-iotests/078 index 7be2c3f691692b6c19e356a57617f432ce089d96..f333e9ac84a7864bb9a3cd778a43a34125fc10ac 100755 --- a/tests/qemu-iotests/078 +++ b/tests/qemu-iotests/078 @@ -25,7 +25,6 @@ seq=`basename $0` echo "QA output created by $seq" here=`pwd` -tmp=/tmp/$$ status=1 # failure is the default! _cleanup() diff --git a/tests/qemu-iotests/079 b/tests/qemu-iotests/079 index ade6efa0d1ae9a4a10e683798c296601e4474ace..b2e3f7426ac2fe1e029b684a1faf5552559f253f 100755 --- a/tests/qemu-iotests/079 +++ b/tests/qemu-iotests/079 @@ -25,7 +25,6 @@ seq=`basename $0` echo "QA output created by $seq" here=`pwd` -tmp=/tmp/$$ status=1 # failure is the default! _cleanup() diff --git a/tests/qemu-iotests/080 b/tests/qemu-iotests/080 index a2c58aebdbc7d527c9db72a30e511b0527fc9902..55044c700bedce5571076319822b20ead8b45a5d 100755 --- a/tests/qemu-iotests/080 +++ b/tests/qemu-iotests/080 @@ -25,7 +25,6 @@ seq=`basename $0` echo "QA output created by $seq" here=`pwd` -tmp=/tmp/$$ status=1 # failure is the default! _cleanup() diff --git a/tests/qemu-iotests/081 b/tests/qemu-iotests/081 index e4b4c6cbf34887386ec79c9c1368a78aa5d625e2..d89fabcdbd2b7e473aeb9236f73616a467373681 100755 --- a/tests/qemu-iotests/081 +++ b/tests/qemu-iotests/081 @@ -25,7 +25,6 @@ seq=`basename $0` echo "QA output created by $seq" here=`pwd` -tmp=/tmp/$$ status=1 # failure is the default! _cleanup() diff --git a/tests/qemu-iotests/082 b/tests/qemu-iotests/082 index c83e01e7cdc9f02dda8ef0ab9e0743c53db53d4c..ad1d9fadc1f929d88d95129f358db7951c220b0c 100755 --- a/tests/qemu-iotests/082 +++ b/tests/qemu-iotests/082 @@ -25,7 +25,6 @@ seq=`basename $0` echo "QA output created by $seq" here=`pwd` -tmp=/tmp/$$ status=1 # failure is the default! _cleanup() diff --git a/tests/qemu-iotests/083 b/tests/qemu-iotests/083 index aa99278fd8540ecd20584645bd04d5301707e0b9..bc724ae05889984eb5f47c27ba2be77df3799904 100755 --- a/tests/qemu-iotests/083 +++ b/tests/qemu-iotests/083 @@ -25,7 +25,6 @@ seq=`basename $0` echo "QA output created by $seq" here=`pwd` -tmp=/tmp/$$ status=1 # failure is the default! # get standard environment, filters and checks diff --git a/tests/qemu-iotests/084 b/tests/qemu-iotests/084 index 733018d4a843dbc8af96b6796e1cd39bb04cf5c4..04f2aa9d7d1cec0376a2d0388233c7e5286316f9 100755 --- a/tests/qemu-iotests/084 +++ b/tests/qemu-iotests/084 @@ -26,7 +26,6 @@ seq=`basename $0` echo "QA output created by $seq" here=`pwd` -tmp=/tmp/$$ status=1 # failure is the default! _cleanup() diff --git a/tests/qemu-iotests/086 b/tests/qemu-iotests/086 index 5527e864fb0286f9e96f0f596cfd541d3a6f14d7..cd4494a6603a4778060e9fac998e945c6b28470e 100755 --- a/tests/qemu-iotests/086 +++ b/tests/qemu-iotests/086 @@ -25,7 +25,6 @@ seq=`basename $0` echo "QA output created by $seq" here=`pwd` -tmp=/tmp/$$ status=1 # failure is the default! _cleanup() diff --git a/tests/qemu-iotests/087 b/tests/qemu-iotests/087 index 27cbebc2bc349622c845a3f3ec12edfe4f60354e..e7bca37efc17ca48795a7c7ca5a0194069e49ddb 100755 --- a/tests/qemu-iotests/087 +++ b/tests/qemu-iotests/087 @@ -25,7 +25,6 @@ seq=`basename $0` echo "QA output created by $seq" here=`pwd` -tmp=/tmp/$$ status=1 # failure is the default! # get standard environment, filters and checks diff --git a/tests/qemu-iotests/088 b/tests/qemu-iotests/088 index f9c312918270aa64188154a1acb27ca404287885..b8076f216b0e0c2bd51df791c115aa2fa8d4ce94 100755 --- a/tests/qemu-iotests/088 +++ b/tests/qemu-iotests/088 @@ -25,7 +25,6 @@ seq=`basename $0` echo "QA output created by $seq" here=`pwd` -tmp=/tmp/$$ status=1 # failure is the default! _cleanup() diff --git a/tests/qemu-iotests/089 b/tests/qemu-iotests/089 index 3e0038dde15ed9404a15ad4db9b0553616081806..9bfe2307b3da5337861da2a71d731c076a571f89 100755 --- a/tests/qemu-iotests/089 +++ b/tests/qemu-iotests/089 @@ -25,7 +25,6 @@ seq="$(basename $0)" echo "QA output created by $seq" here="$PWD" -tmp=/tmp/$$ status=1 # failure is the default! _cleanup() diff --git a/tests/qemu-iotests/090 b/tests/qemu-iotests/090 index 70b5a6fd7305ad597aae21f0445abd281efc65b5..7380503d57c0bfce5c31b3ca819884275e275f6a 100755 --- a/tests/qemu-iotests/090 +++ b/tests/qemu-iotests/090 @@ -25,7 +25,6 @@ seq="$(basename $0)" echo "QA output created by $seq" here="$PWD" -tmp=/tmp/$$ status=1 # failure is the default! _cleanup() diff --git a/tests/qemu-iotests/092 b/tests/qemu-iotests/092 index 52c529bae3a8cf2d104872ba75eb28811fd4445d..5bbdd071d8bd3273c36b198a07e068275036f2fa 100755 --- a/tests/qemu-iotests/092 +++ b/tests/qemu-iotests/092 @@ -25,7 +25,6 @@ seq=`basename $0` echo "QA output created by $seq" here=`pwd` -tmp=/tmp/$$ status=1 # failure is the default! _cleanup() diff --git a/tests/qemu-iotests/094 b/tests/qemu-iotests/094 index 57a68f89e1a00928a094cb7c42404a8500001418..0ba0b0c3615878bdc2f6c18e075a65bd377cfc20 100755 --- a/tests/qemu-iotests/094 +++ b/tests/qemu-iotests/094 @@ -25,7 +25,6 @@ seq="$(basename $0)" echo "QA output created by $seq" here="$PWD" -tmp=/tmp/$$ status=1 # failure is the default! trap "exit \$status" 0 1 2 3 15 diff --git a/tests/qemu-iotests/097 b/tests/qemu-iotests/097 index c7a613b7ee5fd5bb1820b963f9b7531c4fc15522..01d8dd03317a784f13e18669ae7547eb7382e5cb 100755 --- a/tests/qemu-iotests/097 +++ b/tests/qemu-iotests/097 @@ -26,7 +26,6 @@ seq="$(basename $0)" echo "QA output created by $seq" here="$PWD" -tmp=/tmp/$$ status=1 # failure is the default! _cleanup() diff --git a/tests/qemu-iotests/098 b/tests/qemu-iotests/098 index e2230ad60cfa797e293bbaebc4c8bc896cb68b63..b002e969b322fdcf319f6c7bf5dd08d62e08d02c 100755 --- a/tests/qemu-iotests/098 +++ b/tests/qemu-iotests/098 @@ -25,7 +25,6 @@ seq="$(basename $0)" echo "QA output created by $seq" here="$PWD" -tmp=/tmp/$$ status=1 # failure is the default! _cleanup() diff --git a/tests/qemu-iotests/099 b/tests/qemu-iotests/099 index 80f3d9aaf328966ddc6c829e58e6c898be1d75ed..caaf58eee54307a09fe36cbad75a9c81c85a51f3 100755 --- a/tests/qemu-iotests/099 +++ b/tests/qemu-iotests/099 @@ -26,7 +26,6 @@ seq="$(basename $0)" echo "QA output created by $seq" here="$PWD" -tmp=/tmp/$$ status=1 # failure is the default! _cleanup() diff --git a/tests/qemu-iotests/100 b/tests/qemu-iotests/100 index 7c1b235b51506a90b8d489493825620367b61951..5b2fb33330f268b56af560b25e3fa163483b104f 100755 --- a/tests/qemu-iotests/100 +++ b/tests/qemu-iotests/100 @@ -25,7 +25,6 @@ seq=`basename $0` echo "QA output created by $seq" here=`pwd` -tmp=/tmp/$$ status=1 # failure is the default! _cleanup() diff --git a/tests/qemu-iotests/101 b/tests/qemu-iotests/101 index 70fbf25f689a5c260e85484f356d3d463473a863..ea53f8b8d38b3c38a3272acbeb0c6b5e47df9ceb 100755 --- a/tests/qemu-iotests/101 +++ b/tests/qemu-iotests/101 @@ -25,7 +25,6 @@ seq=`basename $0` echo "QA output created by $seq" here=`pwd` -tmp=/tmp/$$ status=1 # failure is the default! _cleanup() diff --git a/tests/qemu-iotests/102 b/tests/qemu-iotests/102 index 161b1974ce5d62736e2ea1ed4d58fae333c714db..64b4af9441dc6285af866ac05ac7df1aee854ef1 100755 --- a/tests/qemu-iotests/102 +++ b/tests/qemu-iotests/102 @@ -25,7 +25,6 @@ seq=$(basename $0) echo "QA output created by $seq" here=$PWD -tmp=/tmp/$$ status=1 # failure is the default! _cleanup() diff --git a/tests/qemu-iotests/103 b/tests/qemu-iotests/103 index fa9a3c1fc9b7f70002dff4af8ae7da4e5a505153..ecbd8ebd71de750b0d117779006530a23e3865d7 100755 --- a/tests/qemu-iotests/103 +++ b/tests/qemu-iotests/103 @@ -25,7 +25,6 @@ seq=$(basename $0) echo "QA output created by $seq" here=$PWD -tmp=/tmp/$$ status=1 # failure is the default! _cleanup() diff --git a/tests/qemu-iotests/104 b/tests/qemu-iotests/104 index 2e35ea80df913b2a3b0ffed143f82cf2fe09d218..726d46705272a01a71358af2b64a80143da566cf 100755 --- a/tests/qemu-iotests/104 +++ b/tests/qemu-iotests/104 @@ -25,7 +25,6 @@ seq=`basename $0` echo "QA output created by $seq" here=`pwd` -tmp=/tmp/$$ status=1 # failure is the default! trap "exit \$status" 0 1 2 3 15 diff --git a/tests/qemu-iotests/105 b/tests/qemu-iotests/105 index 9bae49e3274c523fe81e8d007eeb13bcb022e0f7..3db4ce3cf3e222b109fe7a08d8652c435e640980 100755 --- a/tests/qemu-iotests/105 +++ b/tests/qemu-iotests/105 @@ -25,7 +25,6 @@ seq=`basename $0` echo "QA output created by $seq" here=`pwd` -tmp=/tmp/$$ status=1 # failure is the default! _cleanup() diff --git a/tests/qemu-iotests/107 b/tests/qemu-iotests/107 index 9862030469a1e61fa88e8702a4a2b1697dda896d..d7222dc1c9156eeecc1950962f9364161caa26b5 100755 --- a/tests/qemu-iotests/107 +++ b/tests/qemu-iotests/107 @@ -25,7 +25,6 @@ seq="$(basename $0)" echo "QA output created by $seq" here="$PWD" -tmp=/tmp/$$ status=1 # failure is the default! _cleanup() diff --git a/tests/qemu-iotests/108 b/tests/qemu-iotests/108 index ce447498e9e03740df7f83052de96fb3395eec0a..2355d98c1d35941a51ba62ea416bf3dc7adf7cc1 100755 --- a/tests/qemu-iotests/108 +++ b/tests/qemu-iotests/108 @@ -26,7 +26,6 @@ seq="$(basename $0)" echo "QA output created by $seq" here="$PWD" -tmp=/tmp/$$ status=1 # failure is the default! _cleanup() diff --git a/tests/qemu-iotests/109 b/tests/qemu-iotests/109 index 0b668da850a88f9e9887bce32755d9db90b97136..f980b0c9e509548a0eb9d7db136e90f3b7bbf627 100755 --- a/tests/qemu-iotests/109 +++ b/tests/qemu-iotests/109 @@ -25,7 +25,6 @@ seq="$(basename $0)" echo "QA output created by $seq" here="$PWD" -tmp=/tmp/$$ status=1 # failure is the default! _cleanup() diff --git a/tests/qemu-iotests/110 b/tests/qemu-iotests/110 index a687f9567ddc340463b261e0c2d0af2fd9de722b..9de7369f3ae56e7eed0f76067a46a655e2afed41 100755 --- a/tests/qemu-iotests/110 +++ b/tests/qemu-iotests/110 @@ -25,7 +25,6 @@ seq="$(basename $0)" echo "QA output created by $seq" here="$PWD" -tmp=/tmp/$$ status=1 # failure is the default! _cleanup() diff --git a/tests/qemu-iotests/111 b/tests/qemu-iotests/111 index 6011c94b71240905249f356d493bc55c891fe715..a1c152d0c100410052450ba29f5864964573be96 100755 --- a/tests/qemu-iotests/111 +++ b/tests/qemu-iotests/111 @@ -26,7 +26,6 @@ seq="$(basename $0)" echo "QA output created by $seq" here="$PWD" -tmp=/tmp/$$ status=1 # failure is the default! _cleanup() diff --git a/tests/qemu-iotests/112 b/tests/qemu-iotests/112 index 34ba06acd6f95aeeaed31437856a8d6e5c3880e1..28eb9aae93d9fd11b784bbfe6cb2b840964619b6 100755 --- a/tests/qemu-iotests/112 +++ b/tests/qemu-iotests/112 @@ -25,7 +25,6 @@ seq="$(basename $0)" echo "QA output created by $seq" here="$PWD" -tmp=/tmp/$$ status=1 # failure is the default! _cleanup() diff --git a/tests/qemu-iotests/113 b/tests/qemu-iotests/113 index a2cd96b176c9b80376b058875ad6a6f4bef45ac0..19b68b2727f2e0ae304d3b8b3fa2570a19286f75 100755 --- a/tests/qemu-iotests/113 +++ b/tests/qemu-iotests/113 @@ -26,7 +26,6 @@ seq="$(basename $0)" echo "QA output created by $seq" here="$PWD" -tmp=/tmp/$$ status=1 # failure is the default! _cleanup() diff --git a/tests/qemu-iotests/114 b/tests/qemu-iotests/114 index d02e7ffbe3f60cdfab0ae40e511c1c597ba68380..f110d4f65a011eb3f74bead6b426c4eb39bf1fcc 100755 --- a/tests/qemu-iotests/114 +++ b/tests/qemu-iotests/114 @@ -25,7 +25,6 @@ seq="$(basename $0)" echo "QA output created by $seq" here="$PWD" -tmp=/tmp/$$ status=1 # failure is the default! _cleanup() diff --git a/tests/qemu-iotests/115 b/tests/qemu-iotests/115 index a6be1876aa1618c82efefea26a4bfda062b9cc66..665c2ead41b6f3774e4694140754c675b42ef5f1 100755 --- a/tests/qemu-iotests/115 +++ b/tests/qemu-iotests/115 @@ -25,7 +25,6 @@ seq="$(basename $0)" echo "QA output created by $seq" here="$PWD" -tmp=/tmp/$$ status=1 # failure is the default! _cleanup() diff --git a/tests/qemu-iotests/116 b/tests/qemu-iotests/116 index 713ed484ba7559fb6ede96f4df762ac2ed8b80f0..df0172fed3ad1c9ffdcad90b85e31fa19b301ccc 100755 --- a/tests/qemu-iotests/116 +++ b/tests/qemu-iotests/116 @@ -28,7 +28,6 @@ seq=`basename $0` echo "QA output created by $seq" here=`pwd` -tmp=/tmp/$$ status=1 # failure is the default! _cleanup() diff --git a/tests/qemu-iotests/117 b/tests/qemu-iotests/117 index 969750d1378cb1e4d5425578eef1e52136e6a44c..9385b3f8da450f66bf17f94fdc341b43c1e7120f 100755 --- a/tests/qemu-iotests/117 +++ b/tests/qemu-iotests/117 @@ -25,7 +25,6 @@ seq="$(basename $0)" echo "QA output created by $seq" here="$PWD" -tmp=/tmp/$$ status=1 # failure is the default! _cleanup() diff --git a/tests/qemu-iotests/119 b/tests/qemu-iotests/119 index cc6ec07705d5100d990c39e42ffaf7a11fd53e12..4f34fb4343a7855f7331b618a7f0419818415258 100755 --- a/tests/qemu-iotests/119 +++ b/tests/qemu-iotests/119 @@ -26,7 +26,6 @@ seq="$(basename $0)" echo "QA output created by $seq" here="$PWD" -tmp=/tmp/$$ status=1 # failure is the default! _cleanup() diff --git a/tests/qemu-iotests/120 b/tests/qemu-iotests/120 index d899a3f527c8e2d06473b032f1ad5546f39b52af..4f88a67fe1fa4bfdd0a3ba6851b5ad8b7eb839b5 100755 --- a/tests/qemu-iotests/120 +++ b/tests/qemu-iotests/120 @@ -26,7 +26,6 @@ seq="$(basename $0)" echo "QA output created by $seq" here="$PWD" -tmp=/tmp/$$ status=1 # failure is the default! _cleanup() diff --git a/tests/qemu-iotests/121 b/tests/qemu-iotests/121 index 0912c3f0cb0a29f56b8d6072ca9f927ee26ca48b..1307b4e3279d8d47203b6e5ffeeeafce9501b647 100755 --- a/tests/qemu-iotests/121 +++ b/tests/qemu-iotests/121 @@ -25,7 +25,6 @@ seq="$(basename $0)" echo "QA output created by $seq" here="$PWD" -tmp=/tmp/$$ status=1 # failure is the default! _cleanup() diff --git a/tests/qemu-iotests/122 b/tests/qemu-iotests/122 index 350ca9c46693021d90c4423e737c0fe821a550d9..45b359c2ba056461fd204c01184e0fcdcc2a0d7b 100755 --- a/tests/qemu-iotests/122 +++ b/tests/qemu-iotests/122 @@ -25,7 +25,6 @@ seq="$(basename $0)" echo "QA output created by $seq" here="$PWD" -tmp=/tmp/$$ status=1 # failure is the default! _cleanup() diff --git a/tests/qemu-iotests/123 b/tests/qemu-iotests/123 index ad608035d19b6f2d6ad963e79ccbd340710165bb..b18e3fca9a4ce596cebab63fb22bf9d113812c5a 100755 --- a/tests/qemu-iotests/123 +++ b/tests/qemu-iotests/123 @@ -25,7 +25,6 @@ seq="$(basename $0)" echo "QA output created by $seq" here="$PWD" -tmp=/tmp/$$ status=1 # failure is the default! _cleanup() diff --git a/tests/qemu-iotests/128 b/tests/qemu-iotests/128 index 3d8107d2a34e6c8182b5e5be250611ce577ba771..0976a18133f4887d77d1900053eb3eccbb622b7c 100755 --- a/tests/qemu-iotests/128 +++ b/tests/qemu-iotests/128 @@ -25,7 +25,6 @@ seq=`basename $0` echo "QA output created by $seq" here=`pwd` -tmp=/tmp/$$ status=1 # failure is the default! devname="eiodev$$" diff --git a/tests/qemu-iotests/130 b/tests/qemu-iotests/130 index 9209992daa756ecd0b02ffc610a26a5f9a117a91..ecc8a5ba1b0476163812522c3c893240cd4f43e3 100755 --- a/tests/qemu-iotests/130 +++ b/tests/qemu-iotests/130 @@ -27,7 +27,6 @@ seq="$(basename $0)" echo "QA output created by $seq" here="$PWD" -tmp=/tmp/$$ status=1 # failure is the default! _cleanup() diff --git a/tests/qemu-iotests/131 b/tests/qemu-iotests/131 index 4873f40e944d30a33ef40e2238f4e400f93632b0..94a9ae76af6e7deac8b625be8c9a44f2725c7587 100755 --- a/tests/qemu-iotests/131 +++ b/tests/qemu-iotests/131 @@ -25,7 +25,6 @@ seq=`basename $0` echo "QA output created by $seq" here=`pwd` -tmp=/tmp/$$ status=1 # failure is the default! _cleanup() diff --git a/tests/qemu-iotests/133 b/tests/qemu-iotests/133 index 858710288a38011db6a861cd003d982442d22a77..9d35a6a1ca401740a584723d23218a463ffecd12 100755 --- a/tests/qemu-iotests/133 +++ b/tests/qemu-iotests/133 @@ -25,7 +25,6 @@ seq=`basename $0` echo "QA output created by $seq" here=`pwd` -tmp=/tmp/$$ status=1 # failure is the default! _cleanup() diff --git a/tests/qemu-iotests/134 b/tests/qemu-iotests/134 index 1c3820b17e1aa96dbb778848d4bb543e4cb8a8e3..af618b8817b78182e4ff8a673491963a262d3590 100755 --- a/tests/qemu-iotests/134 +++ b/tests/qemu-iotests/134 @@ -25,7 +25,6 @@ seq=`basename $0` echo "QA output created by $seq" here=`pwd` -tmp=/tmp/$$ status=1 # failure is the default! _cleanup() diff --git a/tests/qemu-iotests/135 b/tests/qemu-iotests/135 index 16bf736560ffb6d86af891ce15b48daa2af71eeb..ce608312f6d7be1ccca0f7afc92ba8fd48a27fbb 100755 --- a/tests/qemu-iotests/135 +++ b/tests/qemu-iotests/135 @@ -25,7 +25,6 @@ seq=`basename $0` echo "QA output created by $seq" here=`pwd` -tmp=/tmp/$$ status=1 # failure is the default! _cleanup() diff --git a/tests/qemu-iotests/137 b/tests/qemu-iotests/137 index 9a6597cf9d52860ca5ad4c9cc3afaef94ae89a25..e5e30de2faf4ad8a5427b85765a3babdb3cfb463 100755 --- a/tests/qemu-iotests/137 +++ b/tests/qemu-iotests/137 @@ -25,7 +25,6 @@ seq="$(basename $0)" echo "QA output created by $seq" here="$PWD" -tmp=/tmp/$$ status=1 # failure is the default! _cleanup() diff --git a/tests/qemu-iotests/138 b/tests/qemu-iotests/138 index a5c3464d58dfb1acc29e99c5c7bc48af1f5d4200..21650d8197fa5ce9d5af865e770f55b235f92b42 100755 --- a/tests/qemu-iotests/138 +++ b/tests/qemu-iotests/138 @@ -25,7 +25,6 @@ seq="$(basename $0)" echo "QA output created by $seq" here="$PWD" -tmp=/tmp/$$ status=1 # failure is the default! _cleanup() diff --git a/tests/qemu-iotests/140 b/tests/qemu-iotests/140 index 05e4506676dbb1cbbf4c51e694afcef86bf80489..49f9df4eb0cfacf931759ee4a6383c6b53480278 100755 --- a/tests/qemu-iotests/140 +++ b/tests/qemu-iotests/140 @@ -29,7 +29,6 @@ seq="$(basename $0)" echo "QA output created by $seq" here="$PWD" -tmp=/tmp/$$ status=1 # failure is the default! _cleanup() diff --git a/tests/qemu-iotests/141 b/tests/qemu-iotests/141 index f7c28b4463714743df610679e60677308eae3468..b2617e5e2b9f27d32b7c893813f1f82dfb3747cb 100755 --- a/tests/qemu-iotests/141 +++ b/tests/qemu-iotests/141 @@ -25,7 +25,6 @@ seq="$(basename $0)" echo "QA output created by $seq" here="$PWD" -tmp=/tmp/$$ status=1 # failure is the default! _cleanup() diff --git a/tests/qemu-iotests/142 b/tests/qemu-iotests/142 index 3828c23b7bee8b2594619b1242869bc7f438131b..29c0606bd7a63f156be0e3c1c5682cc50a9994f7 100755 --- a/tests/qemu-iotests/142 +++ b/tests/qemu-iotests/142 @@ -25,7 +25,6 @@ seq=`basename $0` echo "QA output created by $seq" here=`pwd` -tmp=/tmp/$$ status=1 # failure is the default! _cleanup() diff --git a/tests/qemu-iotests/143 b/tests/qemu-iotests/143 index 6207368f04b3800ca7df5be6557c96212885d944..ec4ef2221aec774131466a18b7a5657f022f215e 100755 --- a/tests/qemu-iotests/143 +++ b/tests/qemu-iotests/143 @@ -25,7 +25,6 @@ seq="$(basename $0)" echo "QA output created by $seq" here="$PWD" -tmp=/tmp/$$ status=1 # failure is the default! _cleanup() diff --git a/tests/qemu-iotests/145 b/tests/qemu-iotests/145 index 7d8febb8cec22932ea7a490b83ab722b9a95f242..1eca0e899059a0c72b356e2910f627ec6c819cfc 100755 --- a/tests/qemu-iotests/145 +++ b/tests/qemu-iotests/145 @@ -25,7 +25,6 @@ seq=`basename $0` echo "QA output created by $seq" here=`pwd` -tmp=/tmp/$$ status=1 # failure is the default! _cleanup() diff --git a/tests/qemu-iotests/150 b/tests/qemu-iotests/150 index 665373deb003faf93a3d6dfcae63d03c446c1679..ee8f6375f695fc172ea26d7214a954032d7fc93b 100755 --- a/tests/qemu-iotests/150 +++ b/tests/qemu-iotests/150 @@ -25,7 +25,6 @@ seq="$(basename $0)" echo "QA output created by $seq" here="$PWD" -tmp=/tmp/$$ status=1 # failure is the default! _cleanup() diff --git a/tests/qemu-iotests/common.config b/tests/qemu-iotests/common.config index 60bfabf348cfe5163ebf369473f615015e5aa795..f824651bac56e7cc8969a0456f2f5e5b3bc77dcf 100644 --- a/tests/qemu-iotests/common.config +++ b/tests/qemu-iotests/common.config @@ -122,7 +122,7 @@ _qemu_img_wrapper() _qemu_io_wrapper() { - local VALGRIND_LOGFILE=/tmp/$$.valgrind + local VALGRIND_LOGFILE="${TEST_DIR}"/$$.valgrind local RETVAL ( if [ "${VALGRIND_QEMU}" == "y" ]; then diff --git a/tests/qemu-iotests/common.filter b/tests/qemu-iotests/common.filter index 84b7434bcf312662bc9872434afd1f94c03e94fe..8a6e1b57c15a8647b377e6cb3a84842b7082b7b6 100644 --- a/tests/qemu-iotests/common.filter +++ b/tests/qemu-iotests/common.filter @@ -19,107 +19,6 @@ # standard filters # -# Checks that given_value is in range of correct_value +/- tolerance. -# Tolerance can be an absolute value or a percentage of the correct value -# (see examples with tolerances below). -# Outputs suitable message to stdout if it's not in range. -# -# A verbose option, -v, may be used as the LAST argument -# -# e.g. -# foo: 0.0298 = 0.03 +/- 5% -# _within_tolerance "foo" 0.0298 0.03 5% -# -# foo: 0.0298 = 0.03 +/- 0.01 -# _within_tolerance "foo" 0.0298 0.03 0.01 -# -# foo: 0.0298 = 0.03 -0.01 +0.002 -# _within_tolerance "foo" 0.0298 0.03 0.01 0.002 -# -# foo: verbose output of 0.0298 = 0.03 +/- 5% -# _within_tolerance "foo" 0.0298 0.03 5% -v -_within_tolerance() -{ - _name=$1 - _given_val=$2 - _correct_val=$3 - _mintol=$4 - _maxtol=$_mintol - _verbose=0 - _debug=false - - # maxtol arg is optional - # verbose arg is optional - if [ $# -ge 5 ] - then - if [ "$5" = "-v" ] - then - _verbose=1 - else - _maxtol=$5 - fi - fi - if [ $# -ge 6 ] - then - [ "$6" = "-v" ] && _verbose=1 - fi - - # find min with or without % - _mintolerance=`echo $_mintol | sed -e 's/%//'` - if [ $_mintol = $_mintolerance ] - then - _min=`echo "scale=5; $_correct_val-$_mintolerance" | bc` - else - _min=`echo "scale=5; $_correct_val-$_mintolerance*0.01*$_correct_val" | bc` - fi - - # find max with or without % - _maxtolerance=`echo $_maxtol | sed -e 's/%//'` - if [ $_maxtol = $_maxtolerance ] - then - _max=`echo "scale=5; $_correct_val+$_maxtolerance" | bc` - else - _max=`echo "scale=5; $_correct_val+$_maxtolerance*0.01*$_correct_val" | bc` - fi - - $_debug && echo "min = $_min" - $_debug && echo "max = $_max" - - cat <$tmp.bc.1 -scale=5; -if ($_min <= $_given_val) 1; -if ($_min > $_given_val) 0; -EOF - - cat <$tmp.bc.2 -scale=5; -if ($_given_val <= $_max) 1; -if ($_given_val > $_max) 0; -EOF - - _above_min=`bc <$tmp.bc.1` - _below_max=`bc <$tmp.bc.2` - - rm -f $tmp.bc.[12] - - _in_range=`expr $_above_min \& $_below_max` - - # fix up min, max precision for output - # can vary for 5.3, 6.2 - _min=`echo $_min | sed -e 's/0*$//'` # get rid of trailling zeroes - _max=`echo $_max | sed -e 's/0*$//'` # get rid of trailling zeroes - - if [ $_in_range -eq 1 ] - then - [ $_verbose -eq 1 ] && echo $_name is in range - return 0 - else - [ $_verbose -eq 1 ] && echo $_name has value of $_given_val - [ $_verbose -eq 1 ] && echo $_name is NOT in range $_min .. $_max - return 1 - fi -} - # ctime(3) dates # _filter_date() diff --git a/tests/qemu-iotests/common.rc b/tests/qemu-iotests/common.rc index d9913f8496207564225651ce9166b79a79957031..5249ec59221de94c70b5da7398648162b008d678 100644 --- a/tests/qemu-iotests/common.rc +++ b/tests/qemu-iotests/common.rc @@ -287,52 +287,6 @@ _need_to_be_root() fi } - -# Do a command, log it to $seq.full, optionally test return status -# and die if command fails. If called with one argument _do executes the -# command, logs it, and returns its exit status. With two arguments _do -# first prints the message passed in the first argument, and then "done" -# or "fail" depending on the return status of the command passed in the -# second argument. If the command fails and the variable _do_die_on_error -# is set to "always" or the two argument form is used and _do_die_on_error -# is set to "message_only" _do will print an error message to -# $seq.out and exit. - -_do() -{ - if [ $# -eq 1 ]; then - _cmd=$1 - elif [ $# -eq 2 ]; then - _note=$1 - _cmd=$2 - echo -n "$_note... " - else - echo "Usage: _do [note] cmd" 1>&2 - status=1; exit - fi - - (eval "echo '---' \"$_cmd\"") >>"$OUTPUT_DIR/$seq.full" - (eval "$_cmd") >$tmp._out 2>&1; ret=$? - cat $tmp._out >>"$OUTPUT_DIR/$seq.full" - if [ $# -eq 2 ]; then - if [ $ret -eq 0 ]; then - echo "done" - else - echo "fail" - fi - fi - if [ $ret -ne 0 ] \ - && [ "$_do_die_on_error" = "always" \ - -o \( $# -eq 2 -a "$_do_die_on_error" = "message_only" \) ] - then - [ $# -ne 2 ] && echo - eval "echo \"$_cmd\" failed \(returned $ret\): see $seq.full" - status=1; exit - fi - - return $ret -} - # bail out, setting up .notrun file # _notrun() diff --git a/tests/qemu-iotests/iotests.py b/tests/qemu-iotests/iotests.py index 0c0b5334b3bebbea436579a3b5e00acf47348145..d9ef60ef0337c300bb2dcf1a32217983ea493ecd 100644 --- a/tests/qemu-iotests/iotests.py +++ b/tests/qemu-iotests/iotests.py @@ -348,6 +348,20 @@ class QMPTestCase(unittest.TestCase): result = self.vm.qmp('query-block-jobs') self.assert_qmp(result, 'return', []) + def assert_has_block_node(self, node_name=None, file_name=None): + """Issue a query-named-block-nodes and assert node_name and/or + file_name is present in the result""" + def check_equal_or_none(a, b): + return a == None or b == None or a == b + assert node_name or file_name + result = self.vm.qmp('query-named-block-nodes') + for x in result["return"]: + if check_equal_or_none(x.get("node-name"), node_name) and \ + check_equal_or_none(x.get("file"), file_name): + return + self.assertTrue(False, "Cannot find %s %s in result:\n%s" % \ + (node_name, file_name, result)) + def cancel_and_wait(self, drive='drive0', force=False, resume=False): '''Cancel a block job and wait for it to finish, returning the event''' result = self.vm.qmp('block-job-cancel', device=drive, force=force)