@@ -8,6 +8,7 @@ IMAGE3=image3
8
8
IMAGES=" ${IMAGE1} ${IMAGE2} ${IMAGE3} "
9
9
10
10
cleanup () {
11
+ kill_nbd_server
11
12
cleanup_tempdir
12
13
remove_images
13
14
}
@@ -65,6 +66,10 @@ remove_images() {
65
66
done
66
67
}
67
68
69
+ kill_nbd_server () {
70
+ pkill -9 qemu-nbd || true
71
+ }
72
+
68
73
show_diff ()
69
74
{
70
75
local file1=$1
390
395
remove_image " ${dest_image} "
391
396
}
392
397
398
+ test_import_nbd_stream () {
399
+ local base_image=$1
400
+ local dest_image=$2
401
+
402
+ qemu-nbd -f qcow2 --read-only --shared 10 --persistent --fork \
403
+ ${TEMPDIR} /${base_image} .qcow2
404
+
405
+ cat > ${TEMPDIR} /spec.json << EOF
406
+ {
407
+ "type": "raw",
408
+ "stream": {
409
+ "type": "nbd",
410
+ "server": "localhost",
411
+ "port": "10809"
412
+ }
413
+ }
414
+ EOF
415
+ cat ${TEMPDIR} /spec.json
416
+
417
+ cat ${TEMPDIR} /spec.json | rbd migration prepare --import-only \
418
+ --source-spec-path - ${dest_image}
419
+ compare_images ${base_image} ${dest_image}
420
+ rbd migration abort ${dest_image}
421
+
422
+ rbd migration prepare --import-only \
423
+ --source-spec-path ${TEMPDIR} /spec.json ${dest_image}
424
+ compare_images ${base_image} ${dest_image}
425
+ rbd migration execute ${dest_image}
426
+ compare_images ${base_image} ${dest_image}
427
+ rbd migration commit ${dest_image}
428
+ compare_images ${base_image} ${dest_image}
429
+ remove_image " ${dest_image} "
430
+
431
+ kill_nbd_server
432
+ }
433
+
393
434
# make sure rbd pool is EMPTY.. this is a test script!!
394
435
rbd ls 2>&1 | wc -l | grep -v ' ^0$' && echo " nonempty rbd pool, aborting! run this script on an empty test cluster only." && exit 1
395
436
@@ -401,7 +442,10 @@ export_base_image ${IMAGE1}
401
442
402
443
test_import_native_format ${IMAGE1} ${IMAGE2}
403
444
test_import_qcow_format ${IMAGE1} ${IMAGE2}
445
+
404
446
test_import_qcow2_format ${IMAGE2} ${IMAGE3}
447
+ test_import_nbd_stream ${IMAGE2} ${IMAGE3}
448
+
405
449
test_import_raw_format ${IMAGE1} ${IMAGE2}
406
450
407
451
echo OK
0 commit comments