mirror of
https://github.com/izzy2lost/xemu.git
synced 2026-07-06 00:20:22 -07:00
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:
+8
-3
@@ -514,6 +514,7 @@ static void floppy_drive_realize(DeviceState *qdev, Error **errp)
|
||||
FloppyDrive *dev = FLOPPY_DRIVE(qdev);
|
||||
FloppyBus *bus = FLOPPY_BUS(qdev->parent_bus);
|
||||
FDrive *drive;
|
||||
bool read_only;
|
||||
int ret;
|
||||
|
||||
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);
|
||||
ret = blk_attach_dev(dev->conf.blk, qdev);
|
||||
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);
|
||||
@@ -559,9 +566,7 @@ static void floppy_drive_realize(DeviceState *qdev, Error **errp)
|
||||
dev->conf.rerror = BLOCKDEV_ON_ERROR_AUTO;
|
||||
dev->conf.werror = BLOCKDEV_ON_ERROR_AUTO;
|
||||
|
||||
if (!blkconf_apply_backend_options(&dev->conf,
|
||||
blk_is_read_only(dev->conf.blk),
|
||||
false, errp)) {
|
||||
if (!blkconf_apply_backend_options(&dev->conf, read_only, false, errp)) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -207,10 +207,11 @@ class GeneralChangeTestsBaseClass(ChangeBaseClass):
|
||||
self.assert_qmp(result, 'return[0]/tray_open', False)
|
||||
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',
|
||||
node_name='new',
|
||||
driver=iotests.imgfmt,
|
||||
read_only=read_only_node,
|
||||
file={'filename': new_img,
|
||||
'driver': 'file'})
|
||||
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]/inserted/image/filename', new_img)
|
||||
|
||||
def test_cycle_read_only_media(self):
|
||||
self.test_cycle(True)
|
||||
|
||||
def test_close_on_closed(self):
|
||||
result = self.vm.qmp('blockdev-close-tray', id=self.device_name)
|
||||
# Should be a no-op
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
...........................................................
|
||||
...............................................................
|
||||
----------------------------------------------------------------------
|
||||
Ran 59 tests
|
||||
Ran 63 tests
|
||||
|
||||
OK
|
||||
|
||||
Reference in New Issue
Block a user