Block layer patches

- Fix crash in blockdev-reopen with iothreads
 - fdc-isa: Respect QOM properties when building AML
 -----BEGIN PGP SIGNATURE-----
 
 iQJFBAABCAAvFiEE3D3rFZqa+V09dFb+fwmycsiPL9YFAmIGoJQRHGt3b2xmQHJl
 ZGhhdC5jb20ACgkQfwmycsiPL9YOzBAAig2bCFiJJds0EpbWPGN/bNGpeAWMSUAi
 lcbp2U+yS/VWEaa/LyD8VfWd8t7gcIXc12bDxHi+/AGgZsR5AQTQclT/kj+Ncmxn
 E2rGTQdXvIZEkfXWYmwbM/Lm2+iK2g0Xw4WfmVj1peT4Mm1hmcle8odnzXywp/dL
 3LLIKVUh7ol/khvQfqR6dbJPhVlbPaKyEmlmdfBjLNYX0FSwRqspKY6GJEj0fZal
 o8wCUA27O8u+ASF3bpk/bFcBcsKAREPi2IXkm+TRFGb+lzolnsO4p7JmOAyE0xaW
 JoMHHU20hGHWMLvvTdOELVNVLp6iz54ZlarUTZFn5pjTbXrT9ELh5d6dfIKQYaGc
 tFpfX+n8dFzqVxAD0/lisAGPxzZYwrHVyVeypJaAMeogPL9+zNKiPdkDEY+1thn8
 Qr3X57qz+saoqH1pGr2Y/x7ZUzA2TKYz0fnN2bHENaAzwNuNJkTKd1+gJ501/ILM
 3v+H2KJKHaKhyxYubRHmCdBod8bOdYCYgZoptEhydhMFQW99dnA6m51h6spWiP1c
 SR+faJxqulnfKu9lTW80+q0akzDArmk8roxNw0Hg0svZfJefKXJKG4oCXy5YU/Fe
 UTAnXx8oWnQpPtnlvCKlMLTKzt6oHGlrE2BED2QPlIk0Mca/9/BwEyu2Yx7AC4Uj
 TkhxAjDdPDg=
 =/1qA
 -----END PGP SIGNATURE-----

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

Block layer patches

- Fix crash in blockdev-reopen with iothreads
- fdc-isa: Respect QOM properties when building AML

# gpg: Signature made Fri 11 Feb 2022 17:44:52 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/kwolf-gitlab/tags/for-upstream:
  hw/block/fdc-isa: Respect QOM properties when building AML
  iotests: Test blockdev-reopen with iothreads and throttling
  block: Lock AioContext for drain_end in blockdev-reopen

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
This commit is contained in:
Peter Maydell 2022-02-14 19:54:00 +00:00
commit 2d88a3a595
4 changed files with 52 additions and 10 deletions

View File

@ -3530,6 +3530,7 @@ void qmp_blockdev_reopen(BlockdevOptionsList *reopen_list, Error **errp)
{ {
BlockReopenQueue *queue = NULL; BlockReopenQueue *queue = NULL;
GSList *drained = NULL; GSList *drained = NULL;
GSList *p;
/* Add each one of the BDS that we want to reopen to the queue */ /* Add each one of the BDS that we want to reopen to the queue */
for (; reopen_list != NULL; reopen_list = reopen_list->next) { for (; reopen_list != NULL; reopen_list = reopen_list->next) {
@ -3579,7 +3580,15 @@ void qmp_blockdev_reopen(BlockdevOptionsList *reopen_list, Error **errp)
fail: fail:
bdrv_reopen_queue_free(queue); bdrv_reopen_queue_free(queue);
g_slist_free_full(drained, (GDestroyNotify) bdrv_subtree_drained_end); for (p = drained; p; p = p->next) {
BlockDriverState *bs = p->data;
AioContext *ctx = bdrv_get_aio_context(bs);
aio_context_acquire(ctx);
bdrv_subtree_drained_end(bs);
aio_context_release(ctx);
}
g_slist_free(drained);
} }
void qmp_blockdev_del(const char *node_name, Error **errp) void qmp_blockdev_del(const char *node_name, Error **errp)

View File

@ -216,6 +216,7 @@ int cmos_get_fd_drive_type(FloppyDriveType fd0)
static void fdc_isa_build_aml(ISADevice *isadev, Aml *scope) static void fdc_isa_build_aml(ISADevice *isadev, Aml *scope)
{ {
FDCtrlISABus *isa = ISA_FDC(isadev);
Aml *dev; Aml *dev;
Aml *crs; Aml *crs;
int i; int i;
@ -227,11 +228,13 @@ static void fdc_isa_build_aml(ISADevice *isadev, Aml *scope)
}; };
crs = aml_resource_template(); crs = aml_resource_template();
aml_append(crs, aml_io(AML_DECODE16, 0x03F2, 0x03F2, 0x00, 0x04));
aml_append(crs, aml_io(AML_DECODE16, 0x03F7, 0x03F7, 0x00, 0x01));
aml_append(crs, aml_irq_no_flags(6));
aml_append(crs, aml_append(crs,
aml_dma(AML_COMPATIBILITY, AML_NOTBUSMASTER, AML_TRANSFER8, 2)); aml_io(AML_DECODE16, isa->iobase + 2, isa->iobase + 2, 0x00, 0x04));
aml_append(crs,
aml_io(AML_DECODE16, isa->iobase + 7, isa->iobase + 7, 0x00, 0x01));
aml_append(crs, aml_irq_no_flags(isa->irq));
aml_append(crs,
aml_dma(AML_COMPATIBILITY, AML_NOTBUSMASTER, AML_TRANSFER8, isa->dma));
dev = aml_device("FDC0"); dev = aml_device("FDC0");
aml_append(dev, aml_name_decl("_HID", aml_eisaid("PNP0700"))); aml_append(dev, aml_name_decl("_HID", aml_eisaid("PNP0700")));

View File

@ -1138,12 +1138,13 @@ class TestBlockdevReopen(iotests.QMPTestCase):
self.assertEqual(self.get_node('hd1'), None) self.assertEqual(self.get_node('hd1'), None)
self.assert_qmp(self.get_node('hd2'), 'ro', True) self.assert_qmp(self.get_node('hd2'), 'ro', True)
def run_test_iothreads(self, iothread_a, iothread_b, errmsg = None): def run_test_iothreads(self, iothread_a, iothread_b, errmsg = None,
opts = hd_opts(0) opts_a = None, opts_b = None):
opts = opts_a or hd_opts(0)
result = self.vm.qmp('blockdev-add', conv_keys = False, **opts) result = self.vm.qmp('blockdev-add', conv_keys = False, **opts)
self.assert_qmp(result, 'return', {}) self.assert_qmp(result, 'return', {})
opts2 = hd_opts(2) opts2 = opts_b or hd_opts(2)
result = self.vm.qmp('blockdev-add', conv_keys = False, **opts2) result = self.vm.qmp('blockdev-add', conv_keys = False, **opts2)
self.assert_qmp(result, 'return', {}) self.assert_qmp(result, 'return', {})
@ -1194,6 +1195,35 @@ class TestBlockdevReopen(iotests.QMPTestCase):
def test_iothreads_switch_overlay(self): def test_iothreads_switch_overlay(self):
self.run_test_iothreads('', 'iothread0') self.run_test_iothreads('', 'iothread0')
def test_iothreads_with_throttling(self):
# Create a throttle-group object
opts = { 'qom-type': 'throttle-group', 'id': 'group0',
'limits': { 'iops-total': 1000 } }
result = self.vm.qmp('object-add', conv_keys = False, **opts)
self.assert_qmp(result, 'return', {})
# Options with a throttle filter between format and protocol
opts = [
{
'driver': iotests.imgfmt,
'node-name': f'hd{idx}',
'file' : {
'node-name': f'hd{idx}-throttle',
'driver': 'throttle',
'throttle-group': 'group0',
'file': {
'driver': 'file',
'node-name': f'hd{idx}-file',
'filename': hd_path[idx],
},
},
}
for idx in (0, 2)
]
self.run_test_iothreads('iothread0', 'iothread0', None,
opts[0], opts[1])
if __name__ == '__main__': if __name__ == '__main__':
iotests.activate_logging() iotests.activate_logging()
iotests.main(supported_fmts=["qcow2"], iotests.main(supported_fmts=["qcow2"],

View File

@ -17,8 +17,8 @@ read 1/1 bytes at offset 262152
read 1/1 bytes at offset 262160 read 1/1 bytes at offset 262160
1 bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) 1 bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
............... ................
---------------------------------------------------------------------- ----------------------------------------------------------------------
Ran 25 tests Ran 26 tests
OK OK