Block layer patches:

- fdc: Fix inserting read-only media in empty drive
 -----BEGIN PGP SIGNATURE-----
 
 iQIcBAABAgAGBQJdQGL+AAoJEH8JsnLIjy/WAQwQAIjFzuqJA9f+51n61zwo9Aj5
 BnkHK8C7Y+DYapTpXQzg/SS5zyS7MVFXqzPX+riAnP3n4rFKk8GsfIUR97i+bo4D
 mIgyfiVicVSpIIhdQUW3RIrYF4BrN4vV8Mz5Bclej89BO6Yh57FLyzmXHLyhbtO+
 qRXDUE8F5tlv81W/ljye1iUqA9HkrullKNW8SsakK0G7YWrGdHXewCb3xeSIxeCs
 cYkCQsU0fbnJgrdpSIIxxDn2AItLqLJOfSKbisMavAkzKyT9mQM+sw/ng6JrClBI
 1tqkNXynZ1lUX34tj4WXoDrpfYPyc6k013AgqjCQOdTGqkbUZIT9dRJWc4W+QP2J
 8OpJKx8lCnRhzdqYXxoptIUW/z/gLMW8877RJl03D0O7OLOrGHvFE9ow25uXBpNH
 74Iq5aKZAn8XJdO/QfWI9nYolQk04J7dxBs+evsdyUz2K1QsnZBaiKn5BLvskYPA
 +dB0BoD2T99SApCb8KbTWCqYqRWJraWBc5Dml2PoU1ffjfiZdbQUdoCRkuLTvNn8
 KsXG4Seg8UA3S4gMKdTnCXZNkOTflFOLH1Sor3JbVROp4ii0t4zORcAXA43T0+QP
 To0UyS/OhSk3RlzofG1IPEBuk2i1VYaCZSllj1sWbSY6XftLp+75JZd2gVPBy8/b
 TAmvsQYf36gP6yNL1Tga
 =lrIS
 -----END PGP SIGNATURE-----

Merge remote-tracking branch 'remotes/kevin/tags/for-upstream' into staging

Block layer patches:

- fdc: Fix inserting read-only media in empty drive

# gpg: Signature made Tue 30 Jul 2019 16:32:14 BST
# gpg:                using RSA key 7F09B272C88F2FD6
# 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/118: Test inserting a read-only medium
  fdc: Fix inserting read-only media in empty drive

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
This commit is contained in:
Peter Maydell 2019-07-30 16:35:17 +01:00
commit 62ae78c77a
3 changed files with 15 additions and 6 deletions

View File

@ -514,6 +514,7 @@ static void floppy_drive_realize(DeviceState *qdev, Error **errp)
FloppyDrive *dev = FLOPPY_DRIVE(qdev); FloppyDrive *dev = FLOPPY_DRIVE(qdev);
FloppyBus *bus = FLOPPY_BUS(qdev->parent_bus); FloppyBus *bus = FLOPPY_BUS(qdev->parent_bus);
FDrive *drive; FDrive *drive;
bool read_only;
int ret; int ret;
if (dev->unit == -1) { if (dev->unit == -1) {
@ -542,6 +543,12 @@ static void floppy_drive_realize(DeviceState *qdev, Error **errp)
dev->conf.blk = blk_new(qemu_get_aio_context(), 0, BLK_PERM_ALL); dev->conf.blk = blk_new(qemu_get_aio_context(), 0, BLK_PERM_ALL);
ret = blk_attach_dev(dev->conf.blk, qdev); ret = blk_attach_dev(dev->conf.blk, qdev);
assert(ret == 0); assert(ret == 0);
/* Don't take write permissions on an empty drive to allow attaching a
* read-only node later */
read_only = true;
} else {
read_only = !blk_bs(dev->conf.blk) || blk_is_read_only(dev->conf.blk);
} }
blkconf_blocksizes(&dev->conf); blkconf_blocksizes(&dev->conf);
@ -559,9 +566,7 @@ static void floppy_drive_realize(DeviceState *qdev, Error **errp)
dev->conf.rerror = BLOCKDEV_ON_ERROR_AUTO; dev->conf.rerror = BLOCKDEV_ON_ERROR_AUTO;
dev->conf.werror = BLOCKDEV_ON_ERROR_AUTO; dev->conf.werror = BLOCKDEV_ON_ERROR_AUTO;
if (!blkconf_apply_backend_options(&dev->conf, if (!blkconf_apply_backend_options(&dev->conf, read_only, false, errp)) {
blk_is_read_only(dev->conf.blk),
false, errp)) {
return; return;
} }

View File

@ -207,10 +207,11 @@ class GeneralChangeTestsBaseClass(ChangeBaseClass):
self.assert_qmp(result, 'return[0]/tray_open', False) self.assert_qmp(result, 'return[0]/tray_open', False)
self.assert_qmp(result, 'return[0]/inserted/image/filename', new_img) self.assert_qmp(result, 'return[0]/inserted/image/filename', new_img)
def test_cycle(self): def test_cycle(self, read_only_node=False):
result = self.vm.qmp('blockdev-add', result = self.vm.qmp('blockdev-add',
node_name='new', node_name='new',
driver=iotests.imgfmt, driver=iotests.imgfmt,
read_only=read_only_node,
file={'filename': new_img, file={'filename': new_img,
'driver': 'file'}) 'driver': 'file'})
self.assert_qmp(result, 'return', {}) self.assert_qmp(result, 'return', {})
@ -257,6 +258,9 @@ class GeneralChangeTestsBaseClass(ChangeBaseClass):
self.assert_qmp(result, 'return[0]/tray_open', False) self.assert_qmp(result, 'return[0]/tray_open', False)
self.assert_qmp(result, 'return[0]/inserted/image/filename', new_img) self.assert_qmp(result, 'return[0]/inserted/image/filename', new_img)
def test_cycle_read_only_media(self):
self.test_cycle(True)
def test_close_on_closed(self): def test_close_on_closed(self):
result = self.vm.qmp('blockdev-close-tray', id=self.device_name) result = self.vm.qmp('blockdev-close-tray', id=self.device_name)
# Should be a no-op # Should be a no-op

View File

@ -1,5 +1,5 @@
........................................................... ...............................................................
---------------------------------------------------------------------- ----------------------------------------------------------------------
Ran 59 tests Ran 63 tests
OK OK