mirror of https://gitee.com/openkylin/qemu.git
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1 iQEcBAABAgAGBQJWX8xEAAoJEJykq7OBq3PIY+YH/0fhpy2S0G2LtfjYX3522Q81 3SsIC+4934+SkGLkQflnNsy8HPKvqQndkV+5FEqbzUTwJ1kjixyKapfpLyA0tvbm +uxvC1Mn91nVfqlfh3zwGOqprcEwPvXtfIyeOlfeq+6m72fDLWUakIwzAfNGWeV8 REc3j2yTEw2esRPKau5kP1q3taN7w6UvIx9I8g1/cbnq89ca0ici/+AhBz/XGGb1 gTlxtBoVWfH+k0kO2rqhZt+RLi7u22cmtPOywOTuqIt3HEYgFdaaf6S0UcZ+mgno CNf0hhbHuMhBCgWvXcGXDssFrI2GoSl8hEuTBbLHyOSFSHZ8pfRLFmoFuZzXW0c= =TtA6 -----END PGP SIGNATURE----- Merge remote-tracking branch 'remotes/stefanha/tags/block-pull-request' into staging # gpg: Signature made Thu 03 Dec 2015 04:59:48 GMT using RSA key ID 81AB73C8 # gpg: Good signature from "Stefan Hajnoczi <stefanha@redhat.com>" # gpg: aka "Stefan Hajnoczi <stefanha@gmail.com>" * remotes/stefanha/tags/block-pull-request: iotests: Add regresion test case for write notifier assertion failure iotests: Add "add_drive_raw" method block: Don't wait serialising for non-COR read requests iothread: include id in thread name Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
This commit is contained in:
commit
efdeb96c5a
|
@ -132,7 +132,7 @@ static int coroutine_fn backup_do_cow(BlockDriverState *bs,
|
|||
qemu_iovec_init_external(&bounce_qiov, &iov, 1);
|
||||
|
||||
if (is_write_notifier) {
|
||||
ret = bdrv_co_no_copy_on_readv(bs,
|
||||
ret = bdrv_co_readv_no_serialising(bs,
|
||||
start * BACKUP_SECTORS_PER_CLUSTER,
|
||||
n, &bounce_qiov);
|
||||
} else {
|
||||
|
|
12
block/io.c
12
block/io.c
|
@ -863,7 +863,9 @@ static int coroutine_fn bdrv_aligned_preadv(BlockDriverState *bs,
|
|||
mark_request_serialising(req, bdrv_get_cluster_size(bs));
|
||||
}
|
||||
|
||||
wait_serialising_requests(req);
|
||||
if (!(flags & BDRV_REQ_NO_SERIALISING)) {
|
||||
wait_serialising_requests(req);
|
||||
}
|
||||
|
||||
if (flags & BDRV_REQ_COPY_ON_READ) {
|
||||
int pnum;
|
||||
|
@ -952,7 +954,7 @@ static int coroutine_fn bdrv_co_do_preadv(BlockDriverState *bs,
|
|||
}
|
||||
|
||||
/* Don't do copy-on-read if we read data before write operation */
|
||||
if (bs->copy_on_read && !(flags & BDRV_REQ_NO_COPY_ON_READ)) {
|
||||
if (bs->copy_on_read && !(flags & BDRV_REQ_NO_SERIALISING)) {
|
||||
flags |= BDRV_REQ_COPY_ON_READ;
|
||||
}
|
||||
|
||||
|
@ -1021,13 +1023,13 @@ int coroutine_fn bdrv_co_readv(BlockDriverState *bs, int64_t sector_num,
|
|||
return bdrv_co_do_readv(bs, sector_num, nb_sectors, qiov, 0);
|
||||
}
|
||||
|
||||
int coroutine_fn bdrv_co_no_copy_on_readv(BlockDriverState *bs,
|
||||
int coroutine_fn bdrv_co_readv_no_serialising(BlockDriverState *bs,
|
||||
int64_t sector_num, int nb_sectors, QEMUIOVector *qiov)
|
||||
{
|
||||
trace_bdrv_co_no_copy_on_readv(bs, sector_num, nb_sectors);
|
||||
trace_bdrv_co_readv_no_serialising(bs, sector_num, nb_sectors);
|
||||
|
||||
return bdrv_co_do_readv(bs, sector_num, nb_sectors, qiov,
|
||||
BDRV_REQ_NO_COPY_ON_READ);
|
||||
BDRV_REQ_NO_SERIALISING);
|
||||
}
|
||||
|
||||
int coroutine_fn bdrv_co_copy_on_readv(BlockDriverState *bs,
|
||||
|
|
|
@ -61,7 +61,7 @@ typedef enum {
|
|||
* opened with BDRV_O_UNMAP.
|
||||
*/
|
||||
BDRV_REQ_MAY_UNMAP = 0x4,
|
||||
BDRV_REQ_NO_COPY_ON_READ = 0x8,
|
||||
BDRV_REQ_NO_SERIALISING = 0x8,
|
||||
} BdrvRequestFlags;
|
||||
|
||||
typedef struct BlockSizes {
|
||||
|
@ -248,7 +248,7 @@ int coroutine_fn bdrv_co_readv(BlockDriverState *bs, int64_t sector_num,
|
|||
int nb_sectors, QEMUIOVector *qiov);
|
||||
int coroutine_fn bdrv_co_copy_on_readv(BlockDriverState *bs,
|
||||
int64_t sector_num, int nb_sectors, QEMUIOVector *qiov);
|
||||
int coroutine_fn bdrv_co_no_copy_on_readv(BlockDriverState *bs,
|
||||
int coroutine_fn bdrv_co_readv_no_serialising(BlockDriverState *bs,
|
||||
int64_t sector_num, int nb_sectors, QEMUIOVector *qiov);
|
||||
int coroutine_fn bdrv_co_writev(BlockDriverState *bs, int64_t sector_num,
|
||||
int nb_sectors, QEMUIOVector *qiov);
|
||||
|
|
|
@ -72,6 +72,7 @@ static void iothread_complete(UserCreatable *obj, Error **errp)
|
|||
{
|
||||
Error *local_error = NULL;
|
||||
IOThread *iothread = IOTHREAD(obj);
|
||||
char *name, *thread_name;
|
||||
|
||||
iothread->stopping = false;
|
||||
iothread->thread_id = -1;
|
||||
|
@ -87,8 +88,12 @@ static void iothread_complete(UserCreatable *obj, Error **errp)
|
|||
/* This assumes we are called from a thread with useful CPU affinity for us
|
||||
* to inherit.
|
||||
*/
|
||||
qemu_thread_create(&iothread->thread, "iothread", iothread_run,
|
||||
name = object_get_canonical_path_component(OBJECT(obj));
|
||||
thread_name = g_strdup_printf("IO %s", name);
|
||||
qemu_thread_create(&iothread->thread, thread_name, iothread_run,
|
||||
iothread, QEMU_THREAD_JOINABLE);
|
||||
g_free(thread_name);
|
||||
g_free(name);
|
||||
|
||||
/* Wait for initialization to complete */
|
||||
qemu_mutex_lock(&iothread->init_done_lock);
|
||||
|
|
|
@ -82,6 +82,31 @@ class TestSyncModesNoneAndTop(iotests.QMPTestCase):
|
|||
time.sleep(1)
|
||||
self.assertEqual(-1, qemu_io('-c', 'read -P0x41 0 512', target_img).find("verification failed"))
|
||||
|
||||
class TestBeforeWriteNotifier(iotests.QMPTestCase):
|
||||
def setUp(self):
|
||||
self.vm = iotests.VM().add_drive_raw("file=blkdebug::null-co://,id=drive0,align=65536,driver=blkdebug")
|
||||
self.vm.launch()
|
||||
|
||||
def tearDown(self):
|
||||
self.vm.shutdown()
|
||||
os.remove(target_img)
|
||||
|
||||
def test_before_write_notifier(self):
|
||||
self.vm.pause_drive("drive0")
|
||||
result = self.vm.qmp('drive-backup', device='drive0',
|
||||
sync='full', target=target_img,
|
||||
format="file", speed=1)
|
||||
self.assert_qmp(result, 'return', {})
|
||||
result = self.vm.qmp('block-job-pause', device="drive0")
|
||||
self.assert_qmp(result, 'return', {})
|
||||
# Speed is low enough that this must be an uncopied range, which will
|
||||
# trigger the before write notifier
|
||||
self.vm.hmp_qemu_io('drive0', 'aio_write -P 1 512512 512')
|
||||
self.vm.resume_drive("drive0")
|
||||
result = self.vm.qmp('block-job-resume', device="drive0")
|
||||
self.assert_qmp(result, 'return', {})
|
||||
event = self.cancel_and_wait()
|
||||
self.assert_qmp(event, 'data/type', 'backup')
|
||||
|
||||
if __name__ == '__main__':
|
||||
iotests.main(supported_fmts=['qcow2', 'qed'])
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
..
|
||||
...
|
||||
----------------------------------------------------------------------
|
||||
Ran 2 tests
|
||||
Ran 3 tests
|
||||
|
||||
OK
|
||||
|
|
|
@ -140,6 +140,11 @@ def add_monitor_telnet(self, ip, port):
|
|||
self._args.append('-monitor')
|
||||
self._args.append(args)
|
||||
|
||||
def add_drive_raw(self, opts):
|
||||
self._args.append('-drive')
|
||||
self._args.append(opts)
|
||||
return self
|
||||
|
||||
def add_drive(self, path, opts='', interface='virtio'):
|
||||
'''Add a virtio-blk drive to the VM'''
|
||||
options = ['if=%s' % interface,
|
||||
|
|
|
@ -69,7 +69,7 @@ bdrv_aio_write_zeroes(void *bs, int64_t sector_num, int nb_sectors, int flags, v
|
|||
bdrv_lock_medium(void *bs, bool locked) "bs %p locked %d"
|
||||
bdrv_co_readv(void *bs, int64_t sector_num, int nb_sector) "bs %p sector_num %"PRId64" nb_sectors %d"
|
||||
bdrv_co_copy_on_readv(void *bs, int64_t sector_num, int nb_sector) "bs %p sector_num %"PRId64" nb_sectors %d"
|
||||
bdrv_co_no_copy_on_readv(void *bs, int64_t sector_num, int nb_sector) "bs %p sector_num %"PRId64" nb_sectors %d"
|
||||
bdrv_co_readv_no_serialising(void *bs, int64_t sector_num, int nb_sector) "bs %p sector_num %"PRId64" nb_sectors %d"
|
||||
bdrv_co_writev(void *bs, int64_t sector_num, int nb_sector) "bs %p sector_num %"PRId64" nb_sectors %d"
|
||||
bdrv_co_write_zeroes(void *bs, int64_t sector_num, int nb_sector, int flags) "bs %p sector_num %"PRId64" nb_sectors %d flags %#x"
|
||||
bdrv_co_io_em(void *bs, int64_t sector_num, int nb_sectors, int is_write, void *acb) "bs %p sector_num %"PRId64" nb_sectors %d is_write %d acb %p"
|
||||
|
|
Loading…
Reference in New Issue