Block patches
The following changes since commit 5ec2eca83dc478ddf24077e02a8b34dd26cd3ff9:
Merge remote-tracking branch 'remotes/awilliam/tags/vfio-updates-20190613.0' into staging (2019-06-14 09:33:55 +0100)
are available in the Git repository at:
https://github.com/XanClic/qemu.git tags/pull-block-2019-06-14
for you to fetch changes up to 21c1ce592a144188dfe59b9e156a97da412a59a2:
iotests: Test qemu-img convert -C --salvage (2019-06-14 15:09:42 +0200)
----------------------------------------------------------------
Block patches:
- Allow blockdev-backup from nodes that are not in qemu's main AIO context to newly added nodes
- Add salvaging mode to qemu-img convert
- Minor fixes to tests, documentation, and for less Valgrind annoyance
----------------------------------------------------------------
Andrey Shinkevich (1):
hw/block/fdc: floppy command FIFO memory initialization
John Snow (6):
blockdev-backup: don't check aio_context too early iotests.py: do not use infinite waits
QEMUMachine: add events_wait method
iotests.py: rewrite run_job to be pickier
iotests: add iotest 256 for testing blockdev-backup across iothread
contexts
event_match: always match on None value
Max Reitz (12):
iotests: Filter 175's allocation information
iotests: Fix intermittent failure in 219
qemu-img: Fix options leakage in img_rebase() qapi/block-core: Overlays are not snapshots
blockdev: Overlays are not snapshots
qemu-img: Move quiet into ImgConvertState
qemu-img: Add salvaging mode to convert
blkdebug: Add @iotype error option
blkdebug: Add "none" event
blkdebug: Inject errors on .bdrv_co_block_status()
iotests: Test qemu-img convert --salvage
iotests: Test qemu-img convert -C --salvage
Vladimir Sementsov-Ogievskiy (1):
iotests: restrict 254 to support only qcow2
qapi/block-core.json | 53 ++++++++--- block/blkdebug.c | 60 ++++++++++-- blockdev.c | 14 +-- hw/block/fdc.c | 1 + qemu-img.c | 106 +++++++++++++++------ python/qemu/__init__.py | 67 ++++++++++---- qemu-img-cmds.hx | 4 +- qemu-img.texi | 4 + tests/qemu-iotests/082 | 1 + tests/qemu-iotests/082.out | 3 + tests/qemu-iotests/085.out | 10 +- tests/qemu-iotests/175 | 26 +++++- tests/qemu-iotests/175.out | 8 +- tests/qemu-iotests/219 | 13 ++- tests/qemu-iotests/251 | 170 ++++++++++++++++++++++++++++++++++ tests/qemu-iotests/251.out | 43 +++++++++ tests/qemu-iotests/254 | 2 + tests/qemu-iotests/256 | 122 ++++++++++++++++++++++++ tests/qemu-iotests/256.out | 119 ++++++++++++++++++++++++ tests/qemu-iotests/group | 2 + tests/qemu-iotests/iotests.py | 60 +++++++----- 21 files changed, 772 insertions(+), 116 deletions(-) create mode 100755 tests/qemu-iotests/251 create mode 100644 tests/qemu-iotests/251.out create mode 100755 tests/qemu-iotests/256 create mode 100644 tests/qemu-iotests/256.out
Signature · 1 line
2.21.0
[Qemu-devel] [PULL 03/20] QEMUMachine: add events_wait method
From: John Snow <[email protected]>
Instead of event_wait which looks for a single event, add an events_wait which can look for any number of events simultaneously. However, it will still only return one at a time, whichever happens first.
Message-id: [email protected]
--- python/qemu/__init__.py | 69 +++++++++++++++++++++++++++++------------ 1 file changed, 49 insertions(+), 20 deletions(-)
python/qemu/__init__.py +49 -20
@@ -402,42 +402,71 @@ class QEMUMachine(object): self._qmp.clear_events() return events - def event_wait(self, name, timeout=60.0, match=None): + @staticmethod + def event_match(event, match=None): """ - Wait for specified timeout on named event in QMP; optionally filter - results by match. + Check if an event matches optional match criteria. - The 'match' is checked to be a recursive subset of the 'event'; skips - branch processing on match's value None - {"foo": {"bar": 1}} matches {"foo": None} - {"foo": {"bar": 1}} does not matches {"foo": {"baz": None}} + The match criteria takes the form of a matching subdict. The event is + checked to be a superset of the subdict, recursively, with matching + values whenever those values are not None. + + Examples, with the subdict queries on the left: + - None matches any object. + - {"foo": None} matches {"foo": {"bar": 1}} + - {"foo": {"baz": None}} does not match {"foo": {"bar": 1}} + - {"foo": {"baz": 2}} matches {"foo": {"bar": 1, "baz": 2}} """ - def event_match(event, match=None): - if match is None: - return True + if match is None: + return True - for key in match: - if key in event: - if isinstance(event[key], dict): - if not event_match(event[key], match[key]): - return False - elif event[key] != match[key]: + for key in match: + if key in event: + if isinstance(event[key], dict): + if not QEMUMachine.event_match(event[key], match[key]): return False - else: + elif event[key] != match[key]: return False + else: + return False + return True - return True + def event_wait(self, name, timeout=60.0, match=None): + """ + event_wait waits for and returns a named event from QMP with a timeout. + + name: The event to wait for. + timeout: QEMUMonitorProtocol.pull_event timeout parameter. + match: Optional match criteria. See event_match for details. + """ + return self.events_wait([(name, match)], timeout) + + def events_wait(self, events, timeout=60.0): + """ + events_wait waits for and returns a named event from QMP with a timeout. + + events: a sequence of (name, match_criteria) tuples. + The match criteria are optional and may be None. + See event_match for details. + timeout: QEMUMonitorProtocol.pull_event timeout parameter. + """ + def _match(event): + for name, match in events: + if (event['event'] == name and + self.event_match(event, match)): + return True + return False # Search cached events for event in self._events: - if (event['event'] == name) and event_match(event, match): + if _match(event): self._events.remove(event) return event # Poll for new events while True: event = self._qmp.pull_event(wait=timeout) - if (event['event'] == name) and event_match(event, match): + if _match(event): return event self._events.append(event)
Signature · 1 line
2.21.0
[Qemu-devel] [PULL 08/20] iotests: Fix intermittent failure in 219
In reply to Max ReitzIn 219, we wait for the job to make progress before we emit its status. This makes the output reliable. We do not wait for any more progress if the job's current-progress already matches its total-progress.
Unfortunately, there is a bug: Right after the job has been started, it's possible that total-progress is still 0. In that case, we may skip the first progress-making step and keep ending up 64 kB short.
To fix that bug, we can simply wait for total-progress to reach 4 MB (the image size) after starting the job.
Message-id: [email protected]
--- tests/qemu-iotests/219 | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-)
tests/qemu-iotests/219 +10 -3
@@ -23,6 +23,8 @@ import iotests iotests.verify_image_format(supported_fmts=['qcow2']) +img_size = 4 * 1024 * 1024 + def pause_wait(vm, job_id): with iotests.Timeout(3, "Timeout waiting for job to pause"): while True:
@@ -62,6 +64,8 @@ def test_pause_resume(vm): iotests.log(vm.qmp('query-jobs')) def test_job_lifecycle(vm, job, job_args, has_ready=False): + global img_size + iotests.log('') iotests.log('') iotests.log('Starting block job: %s (auto-finalize: %s; auto-dismiss: %s)' %
@@ -84,6 +88,10 @@ def test_job_lifecycle(vm, job, job_args, has_ready=False): iotests.log(iotests.filter_qmp_event(vm.event_wait('JOB_STATUS_CHANGE'))) iotests.log(iotests.filter_qmp_event(vm.event_wait('JOB_STATUS_CHANGE'))) + # Wait for total-progress to stabilize + while vm.qmp('query-jobs')['return'][0]['total-progress'] < img_size: + pass + # RUNNING state: # pause/resume should work, complete/finalize/dismiss should error out iotests.log('')
@@ -173,9 +181,8 @@ with iotests.FilePath('disk.img') as disk_path, \ iotests.FilePath('copy.img') as copy_path, \ iotests.VM() as vm: - img_size = '4M' - iotests.qemu_img_create('-f', iotests.imgfmt, disk_path, img_size) - iotests.qemu_io('-c', 'write 0 %s' % (img_size), + iotests.qemu_img_create('-f', iotests.imgfmt, disk_path, str(img_size)) + iotests.qemu_io('-c', 'write 0 %i' % (img_size), '-f', iotests.imgfmt, disk_path) iotests.log('Launching VM...')
Signature · 1 line
2.21.0
[Qemu-devel] [PULL 15/20] qemu-img: Add salvaging mode to convert
In reply to Max ReitzThis adds a salvaging mode (--salvage) to qemu-img convert which ignores read errors and treats the respective areas as containing only zeroes. This can be used for instance to at least partially recover the data from terminally corrupted qcow2 images.
Message-id: [email protected]
--- qemu-img.c | 90 +++++++++++++++++++++++++++++++++++++----------- qemu-img-cmds.hx | 4 +-- qemu-img.texi | 4 +++ 3 files changed, 75 insertions(+), 23 deletions(-)
qemu-img.c +69 -21
@@ -69,6 +69,7 @@ enum {OPTION_SIZE =264 ,OPTION_PREALLOCATION =265 ,OPTION_SHRINK =266 , + OPTION_SALVAGE = 267, }; typedef enum OutputFormat {
@@ -1581,6 +1582,7 @@ typedef struct ImgConvertState {int64_t target_backing_sectors;/* negative if unknown */ bool wr_in_order;bool copy_range; +bool salvage;bool quiet;int min_sparse;int alignment;
@@ -1628,25 +1630,44 @@ static int convert_iteration_sectors(ImgConvertState *s, int64_t sector_num) }if (s->sector_next_status <= sector_num) { -int64_t count = n *BDRV_SECTOR_SIZE ; +uint64_t offset = (sector_num - src_cur_offset) *BDRV_SECTOR_SIZE ; +int64_t count; -if (s->target_has_backing) { +do { + count = n *BDRV_SECTOR_SIZE ; + +if (s->target_has_backing) { + ret =bdrv_block_status (blk_bs (s->src[src_cur]), offset, + count, &count,NULL ,NULL ); + }else { + ret =bdrv_block_status_above (blk_bs (s->src[src_cur]),NULL , + offset, count, &count,NULL , +NULL ); + } + +if (ret <0 ) { +if (s->salvage) { +if (n ==1 ) { +if (!s->quiet) { +warn_report ("error while reading block status at " +"offset %" PRIu64": %s" , offset, +strerror (-ret)); + } +/* Just try to read the data, then */ + ret =BDRV_BLOCK_DATA ; + count =BDRV_SECTOR_SIZE ; + }else { +/* Retry on a shorter range */ + n =DIV_ROUND_UP (n,4 ); + } + }else { +error_report ("error while reading block status at offset " +"%" PRIu64": %s" , offset,strerror (-ret)); +return ret; + } + } + }while (ret <0 ); - ret =bdrv_block_status (blk_bs (s->src[src_cur]), - (sector_num - src_cur_offset) * -BDRV_SECTOR_SIZE , - count, &count,NULL ,NULL ); - }else { - ret =bdrv_block_status_above (blk_bs (s->src[src_cur]),NULL , - (sector_num - src_cur_offset) * -BDRV_SECTOR_SIZE , - count, &count,NULL ,NULL ); - } -if (ret <0 ) { -error_report ("error while reading block status of sector %" PRId64 -": %s" , sector_num,strerror (-ret)); -return ret; - } n =DIV_ROUND_UP (count,BDRV_SECTOR_SIZE );if (ret &BDRV_BLOCK_ZERO ) {
@@ -1683,6 +1704,7 @@ static int convert_iteration_sectors(ImgConvertState *s, int64_t sector_num) static int coroutine_fn convert_co_read(ImgConvertState *s, int64_t sector_num,int nb_sectors,uint8_t *buf) { +uint64_t single_read_until =0 ;int n, ret;assert (nb_sectors <= s->buf_sectors);
@@ -1690,6 +1712,7 @@ static int coroutine_fn convert_co_read(ImgConvertState *s, int64_t sector_num,BlockBackend *blk;int src_cur;int64_t bs_sectors, src_cur_offset; +uint64_t offset;/* In the case of compression with multiple source files, we can get a * nb_sectors that spreads into the next part. So we must be able to
@@ -1698,13 +1721,29 @@ static int coroutine_fn convert_co_read(ImgConvertState *s, int64_t sector_num, blk = s->src[src_cur]; bs_sectors = s->src_sectors[src_cur]; + offset = (sector_num - src_cur_offset) <<BDRV_SECTOR_BITS ; + n =MIN (nb_sectors, bs_sectors - (sector_num - src_cur_offset)); +if (single_read_until > offset) { + n =1 ; + } - ret =blk_co_pread ( - blk, (sector_num - src_cur_offset) <<BDRV_SECTOR_BITS , - n <<BDRV_SECTOR_BITS , buf,0 ); + ret =blk_co_pread (blk, offset, n <<BDRV_SECTOR_BITS , buf,0 );if (ret <0 ) { -return ret; +if (s->salvage) { +if (n >1 ) { + single_read_until = offset + (n <<BDRV_SECTOR_BITS ); +continue ; + }else { +if (!s->quiet) { +warn_report ("error while reading offset %" PRIu64 +": %s" , offset,strerror (-ret)); + } +memset (buf,0 ,BDRV_SECTOR_SIZE ); + } + }else { +return ret; + } } sector_num += n;
@@ -2035,6 +2074,7 @@ static int img_convert(int argc, char **argv) {"image-opts", no_argument, 0, OPTION_IMAGE_OPTS}, {"force-share", no_argument, 0, 'U'}, {"target-image-opts", no_argument, 0, OPTION_TARGET_IMAGE_OPTS}, + {"salvage", no_argument, 0, OPTION_SALVAGE}, {0, 0, 0, 0} }; c = getopt_long(argc, argv, ":hf:O:B:Cco:l:S:pt:T:qnm:WU",
@@ -2152,6 +2192,9 @@ static int img_convert(int argc, char **argv)case OPTION_IMAGE_OPTS : image_opts = true;break ; +case OPTION_SALVAGE : + s.salvage = true; +break ;case OPTION_TARGET_IMAGE_OPTS : tgt_image_opts = true;break ;
@@ -2178,6 +2221,11 @@ static int img_convert(int argc, char **argv) goto fail_getopt; } +if (s.copy_range && s.salvage) { +error_report ("Cannot use copy offloading in salvaging mode" ); + goto fail_getopt; + } +if (tgt_image_opts && !skip_create) {error_report ("--target-image-opts requires use of -n flag" ); goto fail_getopt;
qemu-img-cmds.hx +2 -2
@@ -44,9 +44,9 @@ STEXI ETEXI DEF("convert", img_convert, - "convert [--object objectdef] [--image-opts] [--target-image-opts] [-U] [-C] [-c] [-p] [-q] [-n] [-f fmt] [-t cache] [-T src_cache] [-O output_fmt] [-B backing_file] [-o options] [-l snapshot_param] [-S sparse_size] [-m num_coroutines] [-W] filename [filename2 [...]] output_filename") + "convert [--object objectdef] [--image-opts] [--target-image-opts] [-U] [-C] [-c] [-p] [-q] [-n] [-f fmt] [-t cache] [-T src_cache] [-O output_fmt] [-B backing_file] [-o options] [-l snapshot_param] [-S sparse_size] [-m num_coroutines] [-W] [--salvage] filename [filename2 [...]] output_filename") STEXI -@item convert [--object @var{objectdef}] [--image-opts] [--target-image-opts] [-U] [-C] [-c] [-p] [-q] [-n] [-f @var{fmt}] [-t @var{cache}] [-T @var{src_cache}] [-O @var{output_fmt}] [-B @var{backing_file}] [-o @var{options}] [-l @var{snapshot_param}] [-S @var{sparse_size}] [-m @var{num_coroutines}] [-W] @var{filename} [@var{filename2} [...]] @var{output_filename} +@item convert [--object @var{objectdef}] [--image-opts] [--target-image-opts] [-U] [-C] [-c] [-p] [-q] [-n] [-f @var{fmt}] [-t @var{cache}] [-T @var{src_cache}] [-O @var{output_fmt}] [-B @var{backing_file}] [-o @var{options}] [-l @var{snapshot_param}] [-S @var{sparse_size}] [-m @var{num_coroutines}] [-W] [--salvage] @var{filename} [@var{filename2} [...]] @var{output_filename} ETEXI DEF("create", img_create,
qemu-img.texi +4 -0
@@ -175,6 +175,10 @@ improve performance if the data is remote, such as with NFS or iSCSI backends, but will not automatically sparsify zero sectors, and may result in a fully allocated target image depending on the host support for getting allocation information. +@item --salvage +Try to ignore I/O errors when reading. Unless in quiet mode (@code{-q}), errors +will still be printed. Areas that cannot be read from the source will be +treated as containing only zeroes. @end table Parameters to dd subcommand:
Signature · 1 line
2.21.0
[Qemu-devel] [PULL 01/20] blockdev-backup: don't check aio_context too early
In reply to Max ReitzFrom: John Snow <[email protected]>
in blockdev_backup_prepare, we check to make sure that the target is associated with a compatible aio context. However, do_blockdev_backup is called later and has some logic to move the target to a compatible aio_context. The transaction version will fail certain commands needlessly early as a result.
Allow blockdev_backup_prepare to simply call do_blockdev_backup, which will ultimately decide if the contexts are compatible or not.
Note: the transaction version has always disallowed this operation since its initial commit bd8baecd (2014), whereas the version of qmp_blockdev_backup at the time, from commit c29c1dd312f, tried to enforce the aio_context switch instead. It's not clear, and I can't see from the mailing list archives at the time, why the two functions take a different approach. It wasn't until later in efd7556708b (2016) that the standalone version tried to determine if it could set the context or not.
Message-id: [email protected]
--- blockdev.c | 4 ---- 1 file changed, 4 deletions(-)
blockdev.c +0 -4
@@ -1876,10 +1876,6 @@ static void blockdev_backup_prepare(BlkActionState *common, Error **errp) } aio_context =bdrv_get_aio_context (bs); -if (aio_context !=bdrv_get_aio_context (target)) { -error_setg (errp,"Backup between two IO threads is not implemented" ); -return ; - }aio_context_acquire (aio_context); state->bs = bs;
Signature · 1 line
2.21.0
[Qemu-devel] [PULL 09/20] hw/block/fdc: floppy command FIFO memory initialization
In reply to Max ReitzFrom: Andrey Shinkevich <[email protected]>
The uninitialized memory allocated for the command FIFO of the floppy controller during the VM hardware initialization incurs many unwanted reports by Valgrind when VM state is being saved. That verbosity hardens a search for the real memory issues when the iotests run. Particularly, the patch eliminates 20 unnecessary reports of the Valgrind tool in the iotest #169.
Message-id: 1559154027-282547-1-git-send-email-andrey.shinkevich@virtuozzo.com
--- hw/block/fdc.c | 1 + 1 file changed, 1 insertion(+)
hw/block/fdc.c +1 -0
@@ -2648,6 +2648,7 @@ static void fdctrl_realize_common(DeviceState *dev, FDCtrl *fdctrl,FLOPPY_DPRINTF ("init controller\n" ); fdctrl->fifo =qemu_memalign (512 ,FD_SECTOR_LEN ); +memset (fdctrl->fifo,0 ,FD_SECTOR_LEN ); fdctrl->fifo_size =512 ; fdctrl->result_timer =timer_new_ns (QEMU_CLOCK_VIRTUAL , fdctrl_result_timer, fdctrl);
Signature · 1 line
2.21.0
[Qemu-devel] [PULL 02/20] iotests.py: do not use infinite waits
In reply to Max ReitzFrom: John Snow <[email protected]>
Cap waits to 60 seconds so that iotests can fail gracefully if something goes wrong.
Message-id: [email protected]
--- tests/qemu-iotests/iotests.py | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-)
tests/qemu-iotests/iotests.py +7 -7
@@ -524,7 +524,7 @@ class VM(qtest.QEMUQtestMachine): output_list += [key + '=' + obj[key]] return ','.join(output_list) - def get_qmp_events_filtered(self, wait=True): + def get_qmp_events_filtered(self, wait=60.0): result = [] for ev in self.get_qmp_events(wait=wait): result.append(filter_qmp_event(ev))
@@ -542,10 +542,10 @@ class VM(qtest.QEMUQtestMachine): # Returns None on success, and an error string on failure def run_job(self, job, auto_finalize=True, auto_dismiss=False, - pre_finalize=None): + pre_finalize=None, wait=60.0): error = None while True: - for ev in self.get_qmp_events_filtered(wait=True): + for ev in self.get_qmp_events_filtered(wait=wait): if ev['event'] == 'JOB_STATUS_CHANGE': status = ev['data']['status'] if status == 'aborting':
@@ -650,7 +650,7 @@ class QMPTestCase(unittest.TestCase): self.assertEqual(self.vm.flatten_qmp_object(json.loads(json_filename[5:])), self.vm.flatten_qmp_object(reference)) - def cancel_and_wait(self, drive='drive0', force=False, resume=False): + def cancel_and_wait(self, drive='drive0', force=False, resume=False, wait=60.0): '''Cancel a block job and wait for it to finish, returning the event''' result = self.vm.qmp('block-job-cancel', device=drive, force=force) self.assert_qmp(result, 'return', {})
@@ -661,7 +661,7 @@ class QMPTestCase(unittest.TestCase): cancelled = False result = None while not cancelled: - for event in self.vm.get_qmp_events(wait=True): + for event in self.vm.get_qmp_events(wait=wait): if event['event'] == 'BLOCK_JOB_COMPLETED' or \ event['event'] == 'BLOCK_JOB_CANCELLED': self.assert_qmp(event, 'data/device', drive)
@@ -674,10 +674,10 @@ class QMPTestCase(unittest.TestCase): self.assert_no_active_block_jobs() return result - def wait_until_completed(self, drive='drive0', check_offset=True): + def wait_until_completed(self, drive='drive0', check_offset=True, wait=60.0): '''Wait for a block job to finish, returning the event''' while True: - for event in self.vm.get_qmp_events(wait=True): + for event in self.vm.get_qmp_events(wait=wait): if event['event'] == 'BLOCK_JOB_COMPLETED': self.assert_qmp(event, 'data/device', drive) self.assert_qmp_absent(event, 'data/error')
Signature · 1 line
2.21.0
[Qemu-devel] [PULL 16/20] blkdebug: Add @iotype error option
In reply to Max ReitzThis new error option allows users of blkdebug to inject errors only on certain kinds of I/O operations. Users usually want to make a very specific operation fail, not just any; but right now they simply hope that the event that triggers the error injection is followed up with that very operation. That may not be true, however, because the block layer is changing (including blkdebug, which may increase the number of types of I/O operations on which to inject errors).
The new option's default has been chosen to keep backwards compatibility.
Note that similar to the internal representation, we could choose to expose this option as a list of I/O types. But there is no practical use for this, because as described above, users usually know exactly which kind of operation they want to make fail, so there is no need to specify multiple I/O types at once. In addition, exposing this option as a list would require non-trivial changes to qemu_opts_absorb_qdict().
Message-id: [email protected]
--- qapi/block-core.json | 26 +++++++++++++++++++++++ block/blkdebug.c | 50 ++++++++++++++++++++++++++++++++++++-------- 2 files changed, 67 insertions(+), 9 deletions(-)
qapi/block-core.json +26 -0
@@ -3264,6 +3264,26 @@ 'l1_shrink_write_table', 'l1_shrink_free_l2_clusters', 'cor_write', 'cluster_alloc_space'] } +## +# @BlkdebugIOType: +# +# Kinds of I/O that blkdebug can inject errors in. +# +# @read: .bdrv_co_preadv() +# +# @write: .bdrv_co_pwritev() +# +# @write-zeroes: .bdrv_co_pwrite_zeroes() +# +# @discard: .bdrv_co_pdiscard() +# +# @flush: .bdrv_co_flush_to_disk() +# +# Since: 4.1 +## +{ 'enum': 'BlkdebugIOType', 'prefix': 'BLKDEBUG_IO_TYPE', + 'data': [ 'read', 'write', 'write-zeroes', 'discard', 'flush' ] } + ## # @BlkdebugInjectErrorOptions: #
@@ -3274,6 +3294,11 @@ # @state: the state identifier blkdebug needs to be in to # actually trigger the event; defaults to "any" # +# @iotype: the type of I/O operations on which this error should +# be injected; defaults to "all read, write, +# write-zeroes, discard, and flush operations" +# (since: 4.1) +# # @errno: error identifier (errno) to be returned; defaults to # EIO #
@@ -3291,6 +3316,7 @@ { 'struct': 'BlkdebugInjectErrorOptions', 'data': { 'event': 'BlkdebugEvent', '*state': 'int', + '*iotype': 'BlkdebugIOType', '*errno': 'int', '*sector': 'int', '*once': 'bool',
block/blkdebug.c +41 -9
122 lines not on this page · raw message
Signature · 1 line
2.21.0
[Qemu-devel] [PULL 04/20] iotests.py: rewrite run_job to be pickier
In reply to Max ReitzFrom: John Snow <[email protected]>
Don't pull events out of the queue that don't belong to us; be choosier so that we can use this method to drive jobs that were launched by transactions that may have more jobs.
Message-id: [email protected]
--- tests/qemu-iotests/iotests.py | 48 +++++++++++++++++++++-------------- 1 file changed, 29 insertions(+), 19 deletions(-)
tests/qemu-iotests/iotests.py +29 -19
@@ -543,27 +543,37 @@ class VM(qtest.QEMUQtestMachine): # Returns None on success, and an error string on failure def run_job(self, job, auto_finalize=True, auto_dismiss=False, pre_finalize=None, wait=60.0): + match_device = {'data': {'device': job}} + match_id = {'data': {'id': job}} + events = [ + ('BLOCK_JOB_COMPLETED', match_device), + ('BLOCK_JOB_CANCELLED', match_device), + ('BLOCK_JOB_ERROR', match_device), + ('BLOCK_JOB_READY', match_device), + ('BLOCK_JOB_PENDING', match_id), + ('JOB_STATUS_CHANGE', match_id) + ] error = None while True: - for ev in self.get_qmp_events_filtered(wait=wait): - if ev['event'] == 'JOB_STATUS_CHANGE': - status = ev['data']['status'] - if status == 'aborting': - result = self.qmp('query-jobs') - for j in result['return']: - if j['id'] == job: - error = j['error'] - log('Job failed: %s' % (j['error'])) - elif status == 'pending' and not auto_finalize: - if pre_finalize: - pre_finalize() - self.qmp_log('job-finalize', id=job) - elif status == 'concluded' and not auto_dismiss: - self.qmp_log('job-dismiss', id=job) - elif status == 'null': - return error - else: - log(ev) + ev = filter_qmp_event(self.events_wait(events)) + if ev['event'] != 'JOB_STATUS_CHANGE': + log(ev) + continue + status = ev['data']['status'] + if status == 'aborting': + result = self.qmp('query-jobs') + for j in result['return']: + if j['id'] == job: + error = j['error'] + log('Job failed: %s' % (j['error'])) + elif status == 'pending' and not auto_finalize: + if pre_finalize: + pre_finalize() + self.qmp_log('job-finalize', id=job) + elif status == 'concluded' and not auto_dismiss: + self.qmp_log('job-dismiss', id=job) + elif status == 'null': + return error def node_info(self, node_name): nodes = self.qmp('query-named-block-nodes')
Signature · 1 line
2.21.0
[Qemu-devel] [PULL 06/20] event_match: always match on None value
In reply to Max ReitzFrom: John Snow <[email protected]>
Before, event_match didn't always recurse if the event value was not a dictionary, and would instead check for equality immediately.
By delaying equality checking to post-recursion, we can allow leaf values like "5" to match "None" and take advantage of the generic None-returns-True clause.
This makes the matching a little more obviously consistent at the expense of being able to check for explicit None values, which is probably not that important given what this function is used for.
Message-id: [email protected]
--- python/qemu/__init__.py | 24 ++++++++++++++---------- 1 file changed, 14 insertions(+), 10 deletions(-)
python/qemu/__init__.py +14 -10
@@ -409,27 +409,31 @@ class QEMUMachine(object): The match criteria takes the form of a matching subdict. The event is checked to be a superset of the subdict, recursively, with matching - values whenever those values are not None. + values whenever the subdict values are not None. + + This has a limitation that you cannot explicitly check for None values. Examples, with the subdict queries on the left: - None matches any object. - {"foo": None} matches {"foo": {"bar": 1}} - - {"foo": {"baz": None}} does not match {"foo": {"bar": 1}} - - {"foo": {"baz": 2}} matches {"foo": {"bar": 1, "baz": 2}} + - {"foo": None} matches {"foo": 5} + - {"foo": {"abc": None}} does not match {"foo": {"bar": 1}} + - {"foo": {"rab": 2}} matches {"foo": {"bar": 1, "rab": 2}} """ if match is None: return True - for key in match: - if key in event: - if isinstance(event[key], dict): + try: + for key in match: + if key in event: if not QEMUMachine.event_match(event[key], match[key]): return False - elif event[key] != match[key]: + else: return False - else: - return False - return True + return True + except TypeError: + # either match or event wasn't iterable (not a dict) + return match == event def event_wait(self, name, timeout=60.0, match=None): """
Signature · 1 line
2.21.0
[Qemu-devel] [PULL 05/20] iotests: add iotest 256 for testing blockdev-backup across iothread contexts
In reply to Max ReitzFrom: John Snow <[email protected]>
Message-id: [email protected]
--- tests/qemu-iotests/256 | 122 +++++++++++++++++++++++++++++++++++++ tests/qemu-iotests/256.out | 119 ++++++++++++++++++++++++++++++++++++ tests/qemu-iotests/group | 1 + 3 files changed, 242 insertions(+) create mode 100755 tests/qemu-iotests/256 create mode 100644 tests/qemu-iotests/256.out
tests/qemu-iotests/256 new file +122 -0
@@ -0,0 +1,122 @@ +#!/usr/bin/env python +# +# Test incremental/backup across iothread contexts +# +# Copyright (c) 2019 John Snow for Red Hat, Inc. +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see <http://www.gnu.org/licenses/>. +# +# [email protected] + +import os +import iotests +from iotests import log + +iotests.verify_image_format(supported_fmts=['qcow2']) +size = 64 * 1024 * 1024 + +with iotests.FilePath('img0') as img0_path, \ + iotests.FilePath('img1') as img1_path, \ + iotests.FilePath('img0-full') as img0_full_path, \ + iotests.FilePath('img1-full') as img1_full_path, \ + iotests.FilePath('img0-incr') as img0_incr_path, \ + iotests.FilePath('img1-incr') as img1_incr_path, \ + iotests.VM() as vm: + + def create_target(filepath, name, size): + basename = os.path.basename(filepath) + nodename = "file_{}".format(basename) + log(vm.command('blockdev-create', job_id='job1', + options={ + 'driver': 'file', + 'filename': filepath, + 'size': 0, + })) + vm.run_job('job1') + log(vm.command('blockdev-add', driver='file', + node_name=nodename, filename=filepath)) + log(vm.command('blockdev-create', job_id='job2', + options={ + 'driver': iotests.imgfmt, + 'file': nodename, + 'size': size, + })) + vm.run_job('job2') + log(vm.command('blockdev-add', driver=iotests.imgfmt, + node_name=name, + file=nodename)) + + log('--- Preparing images & VM ---\n') + vm.add_object('iothread,id=iothread0') + vm.add_object('iothread,id=iothread1') + vm.add_device('virtio-scsi-pci,id=scsi0,iothread=iothread0') + vm.add_device('virtio-scsi-pci,id=scsi1,iothread=iothread1') + iotests.qemu_img_create('-f', iotests.imgfmt, img0_path, str(size)) + iotests.qemu_img_create('-f', iotests.imgfmt, img1_path, str(size)) + vm.add_drive(img0_path, interface='none') + vm.add_device('scsi-hd,id=device0,drive=drive0,bus=scsi0.0') + vm.add_drive(img1_path, interface='none') + vm.add_device('scsi-hd,id=device1,drive=drive1,bus=scsi1.0') + + log('--- Starting VM ---\n') + vm.launch() + + log('--- Create Targets & Full Backups ---\n') + create_target(img0_full_path, 'img0-full', size) + create_target(img1_full_path, 'img1-full', size) + ret = vm.qmp_log('transaction', indent=2, actions=[ + { 'type': 'block-dirty-bitmap-add', + 'data': { 'node': 'drive0', 'name': 'bitmap0' }}, + { 'type': 'block-dirty-bitmap-add', + 'data': { 'node': 'drive1', 'name': 'bitmap1' }}, + { 'type': 'blockdev-backup', + 'data': { 'device': 'drive0', + 'target': 'img0-full', + 'sync': 'full', + 'job-id': 'j0' }}, + { 'type': 'blockdev-backup', + 'data': { 'device': 'drive1', + 'target': 'img1-full', + 'sync': 'full', + 'job-id': 'j1' }} + ]) + if "error" in ret: + raise Exception(ret['error']['desc']) + vm.run_job('j0', auto_dismiss=True) + vm.run_job('j1', auto_dismiss=True) + + log('\n--- Create Targets & Incremental Backups ---\n') + create_target(img0_incr_path, 'img0-incr', size) + create_target(img1_incr_path, 'img1-incr', size) + ret = vm.qmp_log('transaction', indent=2, actions=[ + { 'type': 'blockdev-backup', + 'data': { 'device': 'drive0', + 'target': 'img0-incr', + 'sync': 'incremental', + 'bitmap': 'bitmap0', + 'job-id': 'j2' }}, + { 'type': 'blockdev-backup', + 'data': { 'device': 'drive1', + 'target': 'img1-incr', + 'sync': 'incremental', + 'bitmap': 'bitmap1', + 'job-id': 'j3' }} + ]) + if "error" in ret: + raise Exception(ret['error']['desc']) + vm.run_job('j2', auto_dismiss=True) + vm.run_job('j3', auto_dismiss=True) + + log('\n--- Done ---') + vm.shutdown()
tests/qemu-iotests/256.out new file +119 -0
119 lines not on this page · raw message
tests/qemu-iotests/group +1 -0
@@ -267,3 +267,4 @@ 253 rw auto quick 254 rw auto backing quick 255 rw auto quick +256 rw auto quick
Signature · 1 line
2.21.0
[Qemu-devel] [PULL 07/20] iotests: Filter 175's allocation information
In reply to Max ReitzIt is possible for an empty file to take up blocks on a filesystem, for example:
$ qemu-img create -f raw test.img 1G Formatting 'test.img', fmt=raw size=1073741824 $ mkfs.ext4 -I 128 -q test.img $ mkdir test-mount $ sudo mount -o loop test.img test-mount $ sudo touch test-mount/test-file $ stat -c 'blocks=%b' test-mount/test-file blocks=8
These extra blocks (one cluster) are apparently used for metadata, because they are always there, on top of blocks used for data:
$ sudo dd if=/dev/zero of=test-mount/test-file bs=1M count=1 1+0 records in 1+0 records out 1048576 bytes (1.0 MB, 1.0 MiB) copied, 0.00135339 s, 775 MB/s $ stat -c 'blocks=%b' test-mount/test-file blocks=2056
Make iotest 175 take this into account.
Message-id: [email protected]
--- tests/qemu-iotests/175 | 26 ++++++++++++++++++++++---- tests/qemu-iotests/175.out | 8 ++++---- 2 files changed, 26 insertions(+), 8 deletions(-)
tests/qemu-iotests/175 +22 -4
@@ -28,10 +28,25 @@ status=1 # failure is the default! _cleanup() { - _cleanup_test_img + _cleanup_test_img + rm -f "$TEST_DIR/empty" } trap "_cleanup; exit \$status" 0 1 2 3 15 +# Some file systems sometimes allocate extra blocks independently of +# the file size. This function hides the resulting difference in the +# stat -c '%b' output. +# Parameter 1: Number of blocks an empty file occupies +# Parameter 2: Image size in bytes +_filter_blocks() +{ + extra_blocks=$1 + img_size=$2 + + sed -e "s/blocks=$extra_blocks\\(\$\\|[^0-9]\\)/nothing allocated/" \ + -e "s/blocks=$((extra_blocks + img_size / 512))\\(\$\\|[^0-9]\\)/everything allocated/" +} + # get standard environment, filters and checks . ./common.rc . ./common.filter
@@ -40,18 +55,21 @@ _supported_fmt raw _supported_proto file _supported_os Linux -size=1m +size=$((1 * 1024 * 1024)) + +touch "$TEST_DIR/empty" +extra_blocks=$(stat -c '%b' "$TEST_DIR/empty") echo echo "== creating image with default preallocation ==" _make_test_img $size | _filter_imgfmt -stat -c "size=%s, blocks=%b" $TEST_IMG +stat -c "size=%s, blocks=%b" $TEST_IMG | _filter_blocks $extra_blocks $size for mode in off full falloc; do echo echo "== creating image with preallocation $mode ==" IMGOPTS=preallocation=$mode _make_test_img $size | _filter_imgfmt - stat -c "size=%s, blocks=%b" $TEST_IMG + stat -c "size=%s, blocks=%b" $TEST_IMG | _filter_blocks $extra_blocks $size done # success, all done
tests/qemu-iotests/175.out +4 -4
@@ -2,17 +2,17 @@ QA output created by 175 == creating image with default preallocation == Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=1048576 -size=1048576, blocks=0 +size=1048576, nothing allocated == creating image with preallocation off == Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=1048576 preallocation=off -size=1048576, blocks=0 +size=1048576, nothing allocated == creating image with preallocation full == Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=1048576 preallocation=full -size=1048576, blocks=2048 +size=1048576, everything allocated == creating image with preallocation falloc == Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=1048576 preallocation=falloc -size=1048576, blocks=2048 +size=1048576, everything allocated *** done
Signature · 1 line
2.21.0
[Qemu-devel] [PULL 10/20] iotests: restrict 254 to support only qcow2
In reply to Max ReitzFrom: Vladimir Sementsov-Ogievskiy <[email protected]>
Test fails at least for qcow, because of different cluster sizes in base and top (and therefore different granularities of bitmaps we are trying to merge).
The test aim is to check block-dirty-bitmap-merge between different nodes functionality, no needs to check all formats. So, let's just drop support for anything except qcow2.
Message-id: [email protected]
--- tests/qemu-iotests/254 | 2 ++ 1 file changed, 2 insertions(+)
tests/qemu-iotests/254 +2 -0
@@ -21,6 +21,8 @@ import iotests from iotests import qemu_img_create, file_path, log +iotests.verify_image_format(supported_fmts=['qcow2']) + disk, top = file_path('disk', 'top') size = 1024 * 1024
Signature · 1 line
2.21.0
[Qemu-devel] [PULL 19/20] iotests: Test qemu-img convert --salvage
In reply to Max ReitzThis test converts a simple image to another, but blkdebug injects block_status and read faults at some offsets. The resulting image should be the same as the input image, except that sectors that could not be read have to be 0.
Message-id: [email protected]
[mreitz: Dropped superfluous printf from _filter_offsets, as suggested
by Vladimir; disable test for VDI and IMGOPTSSYNTAX]
--- tests/qemu-iotests/251 | 170 +++++++++++++++++++++++++++++++++++++ tests/qemu-iotests/251.out | 43 ++++++++++ tests/qemu-iotests/group | 1 + 3 files changed, 214 insertions(+) create mode 100755 tests/qemu-iotests/251 create mode 100644 tests/qemu-iotests/251.out
tests/qemu-iotests/251 new file +170 -0
@@ -0,0 +1,170 @@ +#!/usr/bin/env bash +# +# Test qemu-img convert --salvage +# +# Copyright (C) 2019 Red Hat, Inc. +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see <http://www.gnu.org/licenses/>. +# + +# creator [email protected] + +seq=$(basename $0) +echo "QA output created by $seq" + +status=1 # failure is the default! + +_cleanup() +{ + _cleanup_test_img +} +trap "_cleanup; exit \$status" 0 1 2 3 15 + +# get standard environment, filters and checks +. ./common.rc +. ./common.filter +. ./common.qemu + +_supported_fmt generic +_supported_proto file +_supported_os Linux + +if [ "$IMGOPTSSYNTAX" = "true" ]; then + # We use json:{} filenames here, so we cannot work with additional options. + _unsupported_fmt $IMGFMT +else + # With VDI, the output is ordered differently. Just disable it. + _unsupported_fmt vdi +fi + + +TEST_IMG="$TEST_IMG.orig" _make_test_img 64M + +$QEMU_IO -c 'write -P 42 0 64M' "$TEST_IMG.orig" | _filter_qemu_io + + +sector_size=512 + +# Offsets on which to fail block-status. Keep in ascending order so +# the indexing done by _filter_offsets will appear in ascending order +# in the output as well. +status_fail_offsets="$((16 * 1024 * 1024 + 8192)) + $((33 * 1024 * 1024 + 512))" + +# Offsets on which to fail reads. Keep in ascending order for the +# same reason. +# The second element is shared with $status_fail_offsets on purpose. +# Starting with the third element, we test what happens when a +# continuous range of sectors is inaccessible. +read_fail_offsets="$((32 * 1024 * 1024 - 65536)) + $((33 * 1024 * 1024 + 512)) + $(seq $((34 * 1024 * 1024)) $sector_size \ + $((34 * 1024 * 1024 + 4096 - $sector_size)))" + + +# blkdebug must be above the format layer so it can intercept all +# block-status events +source_img="json:{'driver': 'blkdebug', + 'image': { + 'driver': '$IMGFMT', + 'file': { + 'driver': 'file', + 'filename': '$TEST_IMG.orig' + } + }, + 'inject-error': [" + +for ofs in $status_fail_offsets +do + source_img+="{ 'event': 'none', + 'iotype': 'block-status', + 'errno': 5, + 'sector': $((ofs / sector_size)) }," +done + +for ofs in $read_fail_offsets +do + source_img+="{ 'event': 'none', + 'iotype': 'read', + 'errno': 5, + 'sector': $((ofs / sector_size)) }," +done + +# Remove the trailing comma and terminate @inject-error and json:{} +source_img="${source_img%,} ] }" + + +echo + + +_filter_offsets() { + filters= + + index=0 + for ofs in $1 + do + filters+=" -e s/$ofs/status_fail_offset_$index/" + index=$((index + 1)) + done + + index=0 + for ofs in $2 + do + filters+=" -e s/$ofs/read_fail_offset_$index/" + index=$((index + 1)) + done + + sed $filters +} + +# While determining the number of allocated sectors in the input +# image, we should see one block status warning per element of +# $status_fail_offsets. +# +# Then, the image is read. Since the block status is queried in +# basically the same way, the same warnings as in the previous step +# should reappear. Interleaved with those we should see a read +# warning per element of $read_fail_offsets. +# Note that $read_fail_offsets and $status_fail_offsets share an +# element (read_fail_offset_1 == status_fail_offset_1), so +# "status_fail_offset_1" in the output is the same as +# "read_fail_offset_1". +$QEMU_IMG convert --salvage "$source_img" "$TEST_IMG" 2>&1 \ + | _filter_offsets "$status_fail_offsets" "$read_fail_offsets" + +echo + +# The offsets where the block status could not be determined should +# have been treated as containing data and thus should be correct in +# the output image. +# The offsets where reading failed altogether should be 0. Make them +# 0 in the input image, too, so we can compare both images. +for ofs in $read_fail_offsets +do + $QEMU_IO -c "write -z $ofs $sector_size" "$TEST_IMG.orig" \ + | _filter_qemu_io \ + | _filter_offsets '' "$read_fail_offsets" +done + +echo + +# These should be equal now. +$QEMU_IMG compare "$TEST_IMG.orig" "$TEST_IMG" + + +# success, all done +echo "*** done" +rm -f $seq.full +status=0
tests/qemu-iotests/251.out new file +43 -0
43 lines not on this page · raw message
tests/qemu-iotests/group +1 -0
@@ -263,6 +263,7 @@ 248 rw quick 249 rw auto quick 250 rw auto quick +251 rw auto quick 252 rw auto backing quick 253 rw auto quick 254 rw auto backing quick
Signature · 1 line
2.21.0
[Qemu-devel] [PULL 12/20] qapi/block-core: Overlays are not snapshots
In reply to Max ReitzA snapshot is something that reflects the state of something at a certain point in time. It does not change.
The file our snapshot commands create (or the node they install) is not a snapshot, as it does change over time. It is an overlay. We cannot do anything about the parameter names, but we can at least adjust the descriptions to reflect that fact.
Message-id: [email protected]
--- qapi/block-core.json | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-)
qapi/block-core.json +10 -10
@@ -1279,17 +1279,17 @@ # # Either @device or @node-name must be set but not both. # -# @device: the name of the device to generate the snapshot from. +# @device: the name of the device to take a snapshot of. # # @node-name: graph node name to generate the snapshot from (Since 2.0) # -# @snapshot-file: the target of the new image. If the file exists, or -# if it is a device, the snapshot will be created in the existing -# file/device. Otherwise, a new file will be created. +# @snapshot-file: the target of the new overlay image. If the file +# exists, or if it is a device, the overlay will be created in the +# existing file/device. Otherwise, a new file will be created. # # @snapshot-node-name: the graph node name of the new image (Since 2.0) # -# @format: the format of the snapshot image, default is 'qcow2'. +# @format: the format of the overlay image, default is 'qcow2'. # # @mode: whether and how QEMU should create a new image, default is # 'absolute-paths'.
@@ -1302,10 +1302,10 @@ ## # @BlockdevSnapshot: # -# @node: device or node name that will have a snapshot created. +# @node: device or node name that will have a snapshot taken. # # @overlay: reference to the existing block device that will become -# the overlay of @node, as part of creating the snapshot. +# the overlay of @node, as part of taking the snapshot. # It must not have a current backing file (this can be # achieved by passing "backing": null to blockdev-add). #
@@ -1443,7 +1443,7 @@ ## # @blockdev-snapshot-sync: # -# Generates a synchronous snapshot of a block device. +# Takes a synchronous snapshot of a block device. # # For the arguments, see the documentation of BlockdevSnapshotSync. #
@@ -1469,9 +1469,9 @@ ## # @blockdev-snapshot: # -# Generates a snapshot of a block device. +# Takes a snapshot of a block device. # -# Create a snapshot, by installing 'node' as the backing image of +# Take a snapshot, by installing 'node' as the backing image of # 'overlay'. Additionally, if 'node' is associated with a block # device, the block device changes to using 'overlay' as its new active # image.
Signature · 1 line
2.21.0
[Qemu-devel] [PULL 14/20] qemu-img: Move quiet into ImgConvertState
In reply to Max ReitzMove img_convert()'s quiet flag into the ImgConvertState so it is accessible by nested functions. -q dictates that it suppresses anything but errors, so if those functions want to emit warnings, they need to query this flag first. (There currently are no such warnings, but there will be as of the next patch.)
Message-id: [email protected]
--- qemu-img.c | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-)
qemu-img.c +7 -6
@@ -1581,6 +1581,7 @@ typedef struct ImgConvertState {int64_t target_backing_sectors;/* negative if unknown */ bool wr_in_order;bool copy_range; +bool quiet;int min_sparse;int alignment;size_t cluster_sectors;
@@ -2012,7 +2013,7 @@ static int img_convert(int argc, char **argv)QDict *open_opts =NULL ;char *options =NULL ;Error *local_err =NULL ; -bool writethrough, src_writethrough, quiet = false, image_opts = false, +bool writethrough, src_writethrough, image_opts = false, skip_create = false, progress = false, tgt_image_opts = false;int64_t ret = -EINVAL ;bool force_share = false;
@@ -2120,7 +2121,7 @@ static int img_convert(int argc, char **argv) src_cache = optarg;break ;case 'q' : - quiet = true; + s.quiet = true;break ;case 'n' : skip_create = true;
@@ -2209,7 +2210,7 @@ static int img_convert(int argc, char **argv) }/* Initialize before goto out */ -if (quiet) { +if (s.quiet) { progress = false; }qemu_progress_init (progress,1.0 );
@@ -2220,7 +2221,7 @@ static int img_convert(int argc, char **argv)for (bs_i =0 ; bs_i < s.src_num; bs_i++) { s.src[bs_i] =img_open (image_opts, argv[optind + bs_i], - fmt, src_flags, src_writethrough, quiet, + fmt, src_flags, src_writethrough, s.quiet, force_share);if (!s.src[bs_i]) { ret =-1 ;
@@ -2383,7 +2384,7 @@ static int img_convert(int argc, char **argv)if (skip_create) { s.target =img_open (tgt_image_opts, out_filename, out_fmt, - flags, writethrough, quiet, false); + flags, writethrough, s.quiet, false); }else {/* TODO ultimately we should allow --target-image-opts * to be used even when -n is not given.
@@ -2391,7 +2392,7 @@ static int img_convert(int argc, char **argv)* to allow filenames in option syntax */ s.target =img_open_file (out_filename, open_opts, out_fmt, - flags, writethrough, quiet, false); + flags, writethrough, s.quiet, false); open_opts =NULL ;/* blk_new_open will have freed it */ }if (!s.target) {
Signature · 1 line
2.21.0
[Qemu-devel] [PULL 20/20] iotests: Test qemu-img convert -C --salvage
In reply to Max ReitzWe do not support this combination (yet), so this should yield an error message.
Message-id: [email protected]
--- tests/qemu-iotests/082 | 1 + tests/qemu-iotests/082.out | 3 +++ 2 files changed, 4 insertions(+)
tests/qemu-iotests/082 +1 -0
@@ -162,6 +162,7 @@ echo === convert: -C and other options === run_qemu_img convert -C -S 4k -O $IMGFMT "$TEST_IMG" "$TEST_IMG".target run_qemu_img convert -C -S 8k -O $IMGFMT "$TEST_IMG" "$TEST_IMG".target run_qemu_img convert -C -c -O $IMGFMT "$TEST_IMG" "$TEST_IMG".target +run_qemu_img convert -C --salvage -O $IMGFMT "$TEST_IMG" "$TEST_IMG".target echo echo === amend: Options specified more than once ===
tests/qemu-iotests/082.out +3 -0
@@ -567,6 +567,9 @@ qemu-img: Cannot enable copy offloading when -S is used Testing: convert -C -c -O qcow2 TEST_DIR/t.qcow2 TEST_DIR/t.qcow2.target qemu-img: Cannot enable copy offloading when -c is used +Testing: convert -C --salvage -O qcow2 TEST_DIR/t.qcow2 TEST_DIR/t.qcow2.target +qemu-img: Cannot use copy offloading in salvaging mode + === amend: Options specified more than once === Testing: amend -f foo -f qcow2 -o lazy_refcounts=on TEST_DIR/t.qcow2
Signature · 1 line
2.21.0
[Qemu-devel] [PULL 11/20] qemu-img: Fix options leakage in img_rebase()
In reply to Max Reitzimg_rebase() can leak a QDict in two occasions. Fix it.
Coverity: CID 1401416
Message-id: [email protected]
--- qemu-img.c | 3 +++ 1 file changed, 3 insertions(+)
qemu-img.c +3 -0
@@ -3350,6 +3350,7 @@ static int img_rebase(int argc, char **argv) out_baseimg, &local_err);if (local_err) { +qobject_unref (options);error_reportf_err (local_err,"Could not resolve backing filename: " ); ret =-1 ;
@@ -3362,7 +3363,9 @@ static int img_rebase(int argc, char **argv)*/ prefix_chain_bs =bdrv_find_backing_image (bs, out_real_path);if (prefix_chain_bs) { +qobject_unref (options);g_free (out_real_path); + blk_new_backing =blk_new (qemu_get_aio_context (),BLK_PERM_CONSISTENT_READ ,BLK_PERM_ALL );
Signature · 1 line
2.21.0
[Qemu-devel] [PULL 13/20] blockdev: Overlays are not snapshots
In reply to Max ReitzThere are error messages which refer to an overlay node as the snapshot. That is wrong, those are two different things.
Message-id: [email protected]
--- blockdev.c | 10 +++++----- tests/qemu-iotests/085.out | 10 +++++----- 2 files changed, 10 insertions(+), 10 deletions(-)
blockdev.c +5 -5
@@ -1608,13 +1608,13 @@ static void external_snapshot_prepare(BlkActionState *common, s->has_snapshot_node_name ? s->snapshot_node_name :NULL ;if (node_name && !snapshot_node_name) { -error_setg (errp,"New snapshot node name missing" ); +error_setg (errp,"New overlay node name missing" ); goto out; }if (snapshot_node_name &&bdrv_lookup_bs (snapshot_node_name, snapshot_node_name,NULL )) { -error_setg (errp,"New snapshot node name already in use" ); +error_setg (errp,"New overlay node name already in use" ); goto out; }
@@ -1656,7 +1656,7 @@ static void external_snapshot_prepare(BlkActionState *common, }if (bdrv_has_blk (state->new_bs)) { -error_setg (errp,"The snapshot is already in use" ); +error_setg (errp,"The overlay is already in use" ); goto out; }
@@ -1666,12 +1666,12 @@ static void external_snapshot_prepare(BlkActionState *common, }if (state->new_bs->backing !=NULL ) { -error_setg (errp,"The snapshot already has a backing image" ); +error_setg (errp,"The overlay already has a backing image" ); goto out; }if (!state->new_bs->drv->supports_backing) { -error_setg (errp,"The snapshot does not support backing images" ); +error_setg (errp,"The overlay does not support backing images" ); goto out; }
tests/qemu-iotests/085.out +5 -5
@@ -64,13 +64,13 @@ Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=134217728 backing_file=TEST_DIR/ === Invalid command - cannot create a snapshot using a file BDS === -{"error": {"class": "GenericError", "desc": "The snapshot does not support backing images"}} +{"error": {"class": "GenericError", "desc": "The overlay does not support backing images"}} === Invalid command - snapshot node used as active layer === -{"error": {"class": "GenericError", "desc": "The snapshot is already in use"}} -{"error": {"class": "GenericError", "desc": "The snapshot is already in use"}} -{"error": {"class": "GenericError", "desc": "The snapshot is already in use"}} +{"error": {"class": "GenericError", "desc": "The overlay is already in use"}} +{"error": {"class": "GenericError", "desc": "The overlay is already in use"}} +{"error": {"class": "GenericError", "desc": "The overlay is already in use"}} === Invalid command - snapshot node used as backing hd ===
@@ -81,7 +81,7 @@ Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=134217728 backing_file=TEST_DIR/ Formatting 'TEST_DIR/t.IMGFMT.base', fmt=IMGFMT size=134217728 Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=134217728 backing_file=TEST_DIR/t.IMGFMT.base {"return": {}} -{"error": {"class": "GenericError", "desc": "The snapshot already has a backing image"}} +{"error": {"class": "GenericError", "desc": "The overlay already has a backing image"}} === Invalid command - The node does not exist ===
Signature · 1 line
2.21.0
[Qemu-devel] [PULL 18/20] blkdebug: Inject errors on .bdrv_co_block_status()
In reply to Max ReitzMessage-id: [email protected]
--- qapi/block-core.json | 5 ++++- block/blkdebug.c | 8 ++++++++ 2 files changed, 12 insertions(+), 1 deletion(-)
qapi/block-core.json +4 -1
@@ -3281,10 +3281,13 @@ # # @flush: .bdrv_co_flush_to_disk() # +# @block-status: .bdrv_co_block_status() +# # Since: 4.1 ## { 'enum': 'BlkdebugIOType', 'prefix': 'BLKDEBUG_IO_TYPE', - 'data': [ 'read', 'write', 'write-zeroes', 'discard', 'flush' ] } + 'data': [ 'read', 'write', 'write-zeroes', 'discard', 'flush', + 'block-status' ] } ## # @BlkdebugInjectErrorOptions:
block/blkdebug.c +8 -0
@@ -670,7 +670,15 @@ static int coroutine_fn blkdebug_co_block_status(BlockDriverState *bs,int64_t *map, BlockDriverState **file) { + int err; +assert (QEMU_IS_ALIGNED (offset | bytes, bs->bl.request_alignment)); + + err =rule_check (bs, offset, bytes,BLKDEBUG_IO_TYPE_BLOCK_STATUS ); +if (err) { +return err; + } +return bdrv_co_block_status_from_file (bs, want_zero, offset, bytes, pnum, map, file); }
Signature · 1 line
2.21.0
[Qemu-devel] [PULL 17/20] blkdebug: Add "none" event
In reply to Max ReitzTogether with @iotypes and @sector, this can be used to trap e.g. the first read or write access to a certain sector without having to know what happens internally in the block layer, i.e. which "real" events happen right before such an access.
Message-id: [email protected]
--- qapi/block-core.json | 4 +++- block/blkdebug.c | 2 ++ 2 files changed, 5 insertions(+), 1 deletion(-)
qapi/block-core.json +3 -1
@@ -3244,6 +3244,8 @@ # # @cluster_alloc_space: an allocation of file space for a cluster (since 4.1) # +# @none: triggers once at creation of the blkdebug node (since 4.1) +# # Since: 2.9 ## { 'enum': 'BlkdebugEvent', 'prefix': 'BLKDBG',
@@ -3262,7 +3264,7 @@ 'pwritev_rmw_tail', 'pwritev_rmw_after_tail', 'pwritev', 'pwritev_zero', 'pwritev_done', 'empty_image_prepare', 'l1_shrink_write_table', 'l1_shrink_free_l2_clusters', - 'cor_write', 'cluster_alloc_space'] } + 'cor_write', 'cluster_alloc_space', 'none'] } ## # @BlkdebugIOType:
block/blkdebug.c +2 -0
@@ -491,6 +491,8 @@ static int blkdebug_open(BlockDriverState *bs, QDict *options, int flags, goto out; } +bdrv_debug_event (bs,BLKDBG_NONE ); + ret =0 ; out:if (ret <0 ) {
Signature · 1 line
2.21.0
Peter Maydell
AppliedQuoted 11 lines · Max Reitz
The following changes since commit
5ec2eca83dc478ddf24077e02a8b34dd26cd3ff9:Merge remote-tracking branch 'remotes/awilliam/tags/vfio-updates-20190613.0' into staging (2019-06-14 09:33:55 +0100)
are available in the Git repository at:
https://github.com/XanClic/qemu.git tags/pull-block-2019-06-14
for you to fetch changes up to
21c1ce592a144188dfe59b9e156a97da412a59a2:
Quoted 9 lines
iotests: Test qemu-img convert -C --salvage (2019-06-14 15:09:42 +0200)----------------------------------------------------------------
Block patches:
- Allow blockdev-backup from nodes that are not in qemu's main AIO context to newly added nodes
- Add salvaging mode to qemu-img convert
- Minor fixes to tests, documentation, and for less Valgrind annoyance
Applied, thanks.
Please update the changelog at https://wiki.qemu.org/ChangeLog/4.1
for any user-visible changes.
-- PMM