diff options
author | Peter Maydell <peter.maydell@linaro.org> | 2021-01-28 12:30:30 +0000 |
---|---|---|
committer | Peter Maydell <peter.maydell@linaro.org> | 2021-01-28 12:30:30 +0000 |
commit | 0bcd12fb1513bad44f05f2d3a8eef2a99b3077b6 (patch) | |
tree | f3649aab45324e1d448b67a7dc1139edf7919374 /tests/qtest | |
parent | 091f255b89e818b84cd003c1da552b6dc3fe3cbd (diff) | |
parent | a44be0334beae3a9affb4a3a92cc6852993d7a84 (diff) |
Merge remote-tracking branch 'remotes/kevin/tags/for-upstream' into staging
Block layer patches:
- Fix crash on write to read-only devices
- iotests: Rewrite 'check' in Python, get rid of 'groups' and allow
non-numeric test case names
# gpg: Signature made Wed 27 Jan 2021 19:56:00 GMT
# gpg: using RSA key DC3DEB159A9AF95D3D7456FE7F09B272C88F2FD6
# gpg: issuer "kwolf@redhat.com"
# gpg: Good signature from "Kevin Wolf <kwolf@redhat.com>" [full]
# Primary key fingerprint: DC3D EB15 9A9A F95D 3D74 56FE 7F09 B272 C88F 2FD6
* remotes/kevin/tags/for-upstream:
iotests: rename and move 169 and 199 tests
iotests: rewrite check into python
iotests: add testrunner.py
iotests: add testenv.py
iotests: add findtests.py
iotests: 146: drop extra whitespaces from .out file
virtio-scsi-test: Test writing to scsi-cd device
block: Separate blk_is_writable() and blk_supports_write_perm()
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Diffstat (limited to 'tests/qtest')
-rw-r--r-- | tests/qtest/virtio-scsi-test.c | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/tests/qtest/virtio-scsi-test.c b/tests/qtest/virtio-scsi-test.c index 0415e75876..1b7ecc1c8f 100644 --- a/tests/qtest/virtio-scsi-test.c +++ b/tests/qtest/virtio-scsi-test.c @@ -200,6 +200,32 @@ static void test_unaligned_write_same(void *obj, void *data, qvirtio_scsi_pci_free(vs); } +static void test_write_to_cdrom(void *obj, void *data, + QGuestAllocator *t_alloc) +{ + QVirtioSCSI *scsi = obj; + QVirtioSCSIQueues *vs; + uint8_t buf[2048] = { 0 }; + const uint8_t write_cdb[VIRTIO_SCSI_CDB_SIZE] = { + /* WRITE(10) to LBA 0, transfer length 1 */ + 0x2a, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00 + }; + struct virtio_scsi_cmd_resp resp; + + alloc = t_alloc; + vs = qvirtio_scsi_init(scsi->vdev); + + virtio_scsi_do_command(vs, write_cdb, NULL, 0, buf, 2048, &resp); + g_assert_cmphex(resp.response, ==, 0); + g_assert_cmphex(resp.status, ==, CHECK_CONDITION); + g_assert_cmphex(resp.sense[0], ==, 0x70); + g_assert_cmphex(resp.sense[2], ==, DATA_PROTECT); + g_assert_cmphex(resp.sense[12], ==, 0x27); /* WRITE PROTECTED */ + g_assert_cmphex(resp.sense[13], ==, 0x00); /* WRITE PROTECTED */ + + qvirtio_scsi_pci_free(vs); +} + static void test_iothread_attach_node(void *obj, void *data, QGuestAllocator *t_alloc) { @@ -267,6 +293,16 @@ static void *virtio_scsi_setup(GString *cmd_line, void *arg) return arg; } +static void *virtio_scsi_setup_cd(GString *cmd_line, void *arg) +{ + g_string_append(cmd_line, + " -drive file=null-co://," + "file.read-zeroes=on," + "if=none,id=dr1,format=raw " + "-device scsi-cd,drive=dr1,lun=0,scsi-id=1"); + return arg; +} + static void *virtio_scsi_setup_iothread(GString *cmd_line, void *arg) { g_string_append(cmd_line, @@ -287,6 +323,9 @@ static void register_virtio_scsi_test(void) qos_add_test("unaligned-write-same", "virtio-scsi", test_unaligned_write_same, &opts); + opts.before = virtio_scsi_setup_cd; + qos_add_test("write-to-cdrom", "virtio-scsi", test_write_to_cdrom, &opts); + opts.before = virtio_scsi_setup_iothread; opts.edge = (QOSGraphEdgeOptions) { .extra_device_opts = "iothread=thread0", |