1903cb1bfSPhilippe Mathieu-Daudé#!/usr/bin/env python3 2eaf1e85dSHanna Reitz# group: rw 39b8c59e7SSergio Lopez# 49b8c59e7SSergio Lopez# Test cases for blockdev + IOThread interactions 59b8c59e7SSergio Lopez# 69b8c59e7SSergio Lopez# Copyright (C) 2019 Red Hat, Inc. 79b8c59e7SSergio Lopez# 89b8c59e7SSergio Lopez# This program is free software; you can redistribute it and/or modify 99b8c59e7SSergio Lopez# it under the terms of the GNU General Public License as published by 109b8c59e7SSergio Lopez# the Free Software Foundation; either version 2 of the License, or 119b8c59e7SSergio Lopez# (at your option) any later version. 129b8c59e7SSergio Lopez# 139b8c59e7SSergio Lopez# This program is distributed in the hope that it will be useful, 149b8c59e7SSergio Lopez# but WITHOUT ANY WARRANTY; without even the implied warranty of 159b8c59e7SSergio Lopez# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 169b8c59e7SSergio Lopez# GNU General Public License for more details. 179b8c59e7SSergio Lopez# 189b8c59e7SSergio Lopez# You should have received a copy of the GNU General Public License 199b8c59e7SSergio Lopez# along with this program. If not, see <http://www.gnu.org/licenses/>. 209b8c59e7SSergio Lopez# 219b8c59e7SSergio Lopez 229b8c59e7SSergio Lopezimport os 23eaf1e85dSHanna Reitzimport time 249b8c59e7SSergio Lopezimport iotests 25eaf1e85dSHanna Reitzfrom iotests import qemu_img, QemuStorageDaemon 269b8c59e7SSergio Lopez 279b8c59e7SSergio Lopezimage_len = 64 * 1024 * 1024 289b8c59e7SSergio Lopez 299b8c59e7SSergio Lopez# Test for RHBZ#1782175 309b8c59e7SSergio Lopezclass TestDirtyBitmapIOThread(iotests.QMPTestCase): 319b8c59e7SSergio Lopez drive0_img = os.path.join(iotests.test_dir, 'drive0.img') 329b8c59e7SSergio Lopez images = { 'drive0': drive0_img } 339b8c59e7SSergio Lopez 349b8c59e7SSergio Lopez def setUp(self): 359b8c59e7SSergio Lopez for name in self.images: 369b8c59e7SSergio Lopez qemu_img('create', '-f', iotests.imgfmt, 379b8c59e7SSergio Lopez self.images[name], str(image_len)) 389b8c59e7SSergio Lopez 399b8c59e7SSergio Lopez self.vm = iotests.VM() 409b8c59e7SSergio Lopez self.vm.add_object('iothread,id=iothread0') 419b8c59e7SSergio Lopez 429b8c59e7SSergio Lopez for name in self.images: 439b8c59e7SSergio Lopez self.vm.add_blockdev('driver=file,filename=%s,node-name=file_%s' 449b8c59e7SSergio Lopez % (self.images[name], name)) 459b8c59e7SSergio Lopez self.vm.add_blockdev('driver=qcow2,file=file_%s,node-name=%s' 469b8c59e7SSergio Lopez % (name, name)) 479b8c59e7SSergio Lopez 489b8c59e7SSergio Lopez self.vm.launch() 499b8c59e7SSergio Lopez self.vm.qmp('x-blockdev-set-iothread', 509b8c59e7SSergio Lopez node_name='drive0', iothread='iothread0', 519b8c59e7SSergio Lopez force=True) 529b8c59e7SSergio Lopez 539b8c59e7SSergio Lopez def tearDown(self): 549b8c59e7SSergio Lopez self.vm.shutdown() 559b8c59e7SSergio Lopez for name in self.images: 569b8c59e7SSergio Lopez os.remove(self.images[name]) 579b8c59e7SSergio Lopez 589b8c59e7SSergio Lopez def test_add_dirty_bitmap(self): 599b8c59e7SSergio Lopez result = self.vm.qmp( 609b8c59e7SSergio Lopez 'block-dirty-bitmap-add', 619b8c59e7SSergio Lopez node='drive0', 629b8c59e7SSergio Lopez name='bitmap1', 639b8c59e7SSergio Lopez persistent=True, 649b8c59e7SSergio Lopez ) 659b8c59e7SSergio Lopez 669b8c59e7SSergio Lopez self.assert_qmp(result, 'return', {}) 679b8c59e7SSergio Lopez 689b8c59e7SSergio Lopez 699b8c59e7SSergio Lopez# Test for RHBZ#1746217 & RHBZ#1773517 709b8c59e7SSergio Lopezclass TestNBDMirrorIOThread(iotests.QMPTestCase): 719b8c59e7SSergio Lopez nbd_sock = os.path.join(iotests.sock_dir, 'nbd.sock') 729b8c59e7SSergio Lopez drive0_img = os.path.join(iotests.test_dir, 'drive0.img') 739b8c59e7SSergio Lopez mirror_img = os.path.join(iotests.test_dir, 'mirror.img') 749b8c59e7SSergio Lopez images = { 'drive0': drive0_img, 'mirror': mirror_img } 759b8c59e7SSergio Lopez 769b8c59e7SSergio Lopez def setUp(self): 779b8c59e7SSergio Lopez for name in self.images: 789b8c59e7SSergio Lopez qemu_img('create', '-f', iotests.imgfmt, 799b8c59e7SSergio Lopez self.images[name], str(image_len)) 809b8c59e7SSergio Lopez 819b8c59e7SSergio Lopez self.vm_src = iotests.VM(path_suffix='src') 829b8c59e7SSergio Lopez self.vm_src.add_object('iothread,id=iothread0') 839b8c59e7SSergio Lopez self.vm_src.add_blockdev('driver=file,filename=%s,node-name=file0' 849b8c59e7SSergio Lopez % (self.drive0_img)) 859b8c59e7SSergio Lopez self.vm_src.add_blockdev('driver=qcow2,file=file0,node-name=drive0') 869b8c59e7SSergio Lopez self.vm_src.launch() 879b8c59e7SSergio Lopez self.vm_src.qmp('x-blockdev-set-iothread', 889b8c59e7SSergio Lopez node_name='drive0', iothread='iothread0', 899b8c59e7SSergio Lopez force=True) 909b8c59e7SSergio Lopez 919b8c59e7SSergio Lopez self.vm_tgt = iotests.VM(path_suffix='tgt') 929b8c59e7SSergio Lopez self.vm_tgt.add_object('iothread,id=iothread0') 939b8c59e7SSergio Lopez self.vm_tgt.add_blockdev('driver=file,filename=%s,node-name=file0' 949b8c59e7SSergio Lopez % (self.mirror_img)) 959b8c59e7SSergio Lopez self.vm_tgt.add_blockdev('driver=qcow2,file=file0,node-name=drive0') 969b8c59e7SSergio Lopez self.vm_tgt.launch() 979b8c59e7SSergio Lopez self.vm_tgt.qmp('x-blockdev-set-iothread', 989b8c59e7SSergio Lopez node_name='drive0', iothread='iothread0', 999b8c59e7SSergio Lopez force=True) 1009b8c59e7SSergio Lopez 1019b8c59e7SSergio Lopez def tearDown(self): 1029b8c59e7SSergio Lopez self.vm_src.shutdown() 1039b8c59e7SSergio Lopez self.vm_tgt.shutdown() 1049b8c59e7SSergio Lopez for name in self.images: 1059b8c59e7SSergio Lopez os.remove(self.images[name]) 1069b8c59e7SSergio Lopez 1079b8c59e7SSergio Lopez def test_nbd_mirror(self): 1089b8c59e7SSergio Lopez result = self.vm_tgt.qmp( 1099b8c59e7SSergio Lopez 'nbd-server-start', 1109b8c59e7SSergio Lopez addr={ 1119b8c59e7SSergio Lopez 'type': 'unix', 1129b8c59e7SSergio Lopez 'data': { 'path': self.nbd_sock } 1139b8c59e7SSergio Lopez } 1149b8c59e7SSergio Lopez ) 1159b8c59e7SSergio Lopez self.assert_qmp(result, 'return', {}) 1169b8c59e7SSergio Lopez 1179b8c59e7SSergio Lopez result = self.vm_tgt.qmp( 1189b8c59e7SSergio Lopez 'nbd-server-add', 1199b8c59e7SSergio Lopez device='drive0', 1209b8c59e7SSergio Lopez writable=True 1219b8c59e7SSergio Lopez ) 1229b8c59e7SSergio Lopez self.assert_qmp(result, 'return', {}) 1239b8c59e7SSergio Lopez 1249b8c59e7SSergio Lopez result = self.vm_src.qmp( 1259b8c59e7SSergio Lopez 'drive-mirror', 1269b8c59e7SSergio Lopez device='drive0', 1279b8c59e7SSergio Lopez target='nbd+unix:///drive0?socket=' + self.nbd_sock, 1289b8c59e7SSergio Lopez sync='full', 1299b8c59e7SSergio Lopez mode='existing', 1309b8c59e7SSergio Lopez speed=64*1024*1024, 1319b8c59e7SSergio Lopez job_id='j1' 1329b8c59e7SSergio Lopez ) 1339b8c59e7SSergio Lopez self.assert_qmp(result, 'return', {}) 1349b8c59e7SSergio Lopez 1359b8c59e7SSergio Lopez self.vm_src.event_wait(name="BLOCK_JOB_READY") 1369b8c59e7SSergio Lopez 1379b8c59e7SSergio Lopez 1389b8c59e7SSergio Lopez# Test for RHBZ#1779036 1399b8c59e7SSergio Lopezclass TestExternalSnapshotAbort(iotests.QMPTestCase): 1409b8c59e7SSergio Lopez drive0_img = os.path.join(iotests.test_dir, 'drive0.img') 1419b8c59e7SSergio Lopez snapshot_img = os.path.join(iotests.test_dir, 'snapshot.img') 1429b8c59e7SSergio Lopez images = { 'drive0': drive0_img, 'snapshot': snapshot_img } 1439b8c59e7SSergio Lopez 1449b8c59e7SSergio Lopez def setUp(self): 1459b8c59e7SSergio Lopez for name in self.images: 1469b8c59e7SSergio Lopez qemu_img('create', '-f', iotests.imgfmt, 1479b8c59e7SSergio Lopez self.images[name], str(image_len)) 1489b8c59e7SSergio Lopez 1499b8c59e7SSergio Lopez self.vm = iotests.VM() 1509b8c59e7SSergio Lopez self.vm.add_object('iothread,id=iothread0') 1519b8c59e7SSergio Lopez self.vm.add_blockdev('driver=file,filename=%s,node-name=file0' 1529b8c59e7SSergio Lopez % (self.drive0_img)) 1539b8c59e7SSergio Lopez self.vm.add_blockdev('driver=qcow2,file=file0,node-name=drive0') 1549b8c59e7SSergio Lopez self.vm.launch() 1559b8c59e7SSergio Lopez self.vm.qmp('x-blockdev-set-iothread', 1569b8c59e7SSergio Lopez node_name='drive0', iothread='iothread0', 1579b8c59e7SSergio Lopez force=True) 1589b8c59e7SSergio Lopez 1599b8c59e7SSergio Lopez def tearDown(self): 1609b8c59e7SSergio Lopez self.vm.shutdown() 1619b8c59e7SSergio Lopez for name in self.images: 1629b8c59e7SSergio Lopez os.remove(self.images[name]) 1639b8c59e7SSergio Lopez 1649b8c59e7SSergio Lopez def test_external_snapshot_abort(self): 1659b8c59e7SSergio Lopez # Use a two actions transaction with a bogus values on the second 1669b8c59e7SSergio Lopez # one to trigger an abort of the transaction. 1679b8c59e7SSergio Lopez result = self.vm.qmp('transaction', actions=[ 1689b8c59e7SSergio Lopez { 1699b8c59e7SSergio Lopez 'type': 'blockdev-snapshot-sync', 1709b8c59e7SSergio Lopez 'data': { 'node-name': 'drive0', 1719b8c59e7SSergio Lopez 'snapshot-file': self.snapshot_img, 1729b8c59e7SSergio Lopez 'snapshot-node-name': 'snap1', 1739b8c59e7SSergio Lopez 'mode': 'absolute-paths', 1749b8c59e7SSergio Lopez 'format': 'qcow2' } 1759b8c59e7SSergio Lopez }, 1769b8c59e7SSergio Lopez { 1779b8c59e7SSergio Lopez 'type': 'blockdev-snapshot-sync', 1789b8c59e7SSergio Lopez 'data': { 'node-name': 'drive0', 1799b8c59e7SSergio Lopez 'snapshot-file': '/fakesnapshot', 1809b8c59e7SSergio Lopez 'snapshot-node-name': 'snap2', 1819b8c59e7SSergio Lopez 'mode': 'absolute-paths', 1829b8c59e7SSergio Lopez 'format': 'qcow2' } 1839b8c59e7SSergio Lopez }, 1849b8c59e7SSergio Lopez ]) 1859b8c59e7SSergio Lopez 1869b8c59e7SSergio Lopez # Crashes on failure, we expect this error. 1879b8c59e7SSergio Lopez self.assert_qmp(result, 'error/class', 'GenericError') 1889b8c59e7SSergio Lopez 1899b8c59e7SSergio Lopez 1909b8c59e7SSergio Lopez# Test for RHBZ#1782111 1919b8c59e7SSergio Lopezclass TestBlockdevBackupAbort(iotests.QMPTestCase): 1929b8c59e7SSergio Lopez drive0_img = os.path.join(iotests.test_dir, 'drive0.img') 1939b8c59e7SSergio Lopez drive1_img = os.path.join(iotests.test_dir, 'drive1.img') 1949b8c59e7SSergio Lopez snap0_img = os.path.join(iotests.test_dir, 'snap0.img') 1959b8c59e7SSergio Lopez snap1_img = os.path.join(iotests.test_dir, 'snap1.img') 1969b8c59e7SSergio Lopez images = { 'drive0': drive0_img, 1979b8c59e7SSergio Lopez 'drive1': drive1_img, 1989b8c59e7SSergio Lopez 'snap0': snap0_img, 1999b8c59e7SSergio Lopez 'snap1': snap1_img } 2009b8c59e7SSergio Lopez 2019b8c59e7SSergio Lopez def setUp(self): 2029b8c59e7SSergio Lopez for name in self.images: 2039b8c59e7SSergio Lopez qemu_img('create', '-f', iotests.imgfmt, 2049b8c59e7SSergio Lopez self.images[name], str(image_len)) 2059b8c59e7SSergio Lopez 2069b8c59e7SSergio Lopez self.vm = iotests.VM() 2079b8c59e7SSergio Lopez self.vm.add_object('iothread,id=iothread0') 2089b8c59e7SSergio Lopez self.vm.add_device('virtio-scsi,iothread=iothread0') 2099b8c59e7SSergio Lopez 2109b8c59e7SSergio Lopez for name in self.images: 2119b8c59e7SSergio Lopez self.vm.add_blockdev('driver=file,filename=%s,node-name=file_%s' 2129b8c59e7SSergio Lopez % (self.images[name], name)) 2139b8c59e7SSergio Lopez self.vm.add_blockdev('driver=qcow2,file=file_%s,node-name=%s' 2149b8c59e7SSergio Lopez % (name, name)) 2159b8c59e7SSergio Lopez 2169b8c59e7SSergio Lopez self.vm.add_device('scsi-hd,drive=drive0') 2179b8c59e7SSergio Lopez self.vm.add_device('scsi-hd,drive=drive1') 2189b8c59e7SSergio Lopez self.vm.launch() 2199b8c59e7SSergio Lopez 2209b8c59e7SSergio Lopez def tearDown(self): 2219b8c59e7SSergio Lopez self.vm.shutdown() 2229b8c59e7SSergio Lopez for name in self.images: 2239b8c59e7SSergio Lopez os.remove(self.images[name]) 2249b8c59e7SSergio Lopez 2259b8c59e7SSergio Lopez def test_blockdev_backup_abort(self): 2269b8c59e7SSergio Lopez # Use a two actions transaction with a bogus values on the second 2279b8c59e7SSergio Lopez # one to trigger an abort of the transaction. 2289b8c59e7SSergio Lopez result = self.vm.qmp('transaction', actions=[ 2299b8c59e7SSergio Lopez { 2309b8c59e7SSergio Lopez 'type': 'blockdev-backup', 2319b8c59e7SSergio Lopez 'data': { 'device': 'drive0', 2329b8c59e7SSergio Lopez 'target': 'snap0', 2339b8c59e7SSergio Lopez 'sync': 'full', 2349b8c59e7SSergio Lopez 'job-id': 'j1' } 2359b8c59e7SSergio Lopez }, 2369b8c59e7SSergio Lopez { 2379b8c59e7SSergio Lopez 'type': 'blockdev-backup', 2389b8c59e7SSergio Lopez 'data': { 'device': 'drive1', 2399b8c59e7SSergio Lopez 'target': 'snap1', 2409b8c59e7SSergio Lopez 'sync': 'full' } 2419b8c59e7SSergio Lopez }, 2429b8c59e7SSergio Lopez ]) 2439b8c59e7SSergio Lopez 2449b8c59e7SSergio Lopez # Hangs on failure, we expect this error. 2459b8c59e7SSergio Lopez self.assert_qmp(result, 'error/class', 'GenericError') 2469b8c59e7SSergio Lopez 247eaf1e85dSHanna Reitz# Test for RHBZ#2033626 248eaf1e85dSHanna Reitzclass TestYieldingAndTimers(iotests.QMPTestCase): 249eaf1e85dSHanna Reitz sock = os.path.join(iotests.sock_dir, 'nbd.sock') 250eaf1e85dSHanna Reitz qsd = None 251eaf1e85dSHanna Reitz 252eaf1e85dSHanna Reitz def setUp(self): 253eaf1e85dSHanna Reitz self.create_nbd_export() 254eaf1e85dSHanna Reitz 255eaf1e85dSHanna Reitz # Simple VM with an NBD block device connected to the NBD export 256*8cfbe929SHanna Reitz # provided by the QSD, and an (initially unused) iothread 257eaf1e85dSHanna Reitz self.vm = iotests.VM() 258*8cfbe929SHanna Reitz self.vm.add_object('iothread,id=iothr') 259eaf1e85dSHanna Reitz self.vm.add_blockdev('nbd,node-name=nbd,server.type=unix,' + 260eaf1e85dSHanna Reitz f'server.path={self.sock},export=exp,' + 261eaf1e85dSHanna Reitz 'reconnect-delay=1,open-timeout=1') 262eaf1e85dSHanna Reitz 263eaf1e85dSHanna Reitz self.vm.launch() 264eaf1e85dSHanna Reitz 265eaf1e85dSHanna Reitz def tearDown(self): 266eaf1e85dSHanna Reitz self.stop_nbd_export() 267eaf1e85dSHanna Reitz self.vm.shutdown() 268eaf1e85dSHanna Reitz 269eaf1e85dSHanna Reitz def test_timers_with_blockdev_del(self): 270eaf1e85dSHanna Reitz # The NBD BDS will have had an active open timer, because setUp() gave 271eaf1e85dSHanna Reitz # a positive value for @open-timeout. It should be gone once the BDS 272eaf1e85dSHanna Reitz # has been opened. 273eaf1e85dSHanna Reitz # (But there used to be a bug where it remained active, which will 274eaf1e85dSHanna Reitz # become important below.) 275eaf1e85dSHanna Reitz 276eaf1e85dSHanna Reitz # Stop and restart the NBD server, and do some I/O on the client to 277eaf1e85dSHanna Reitz # trigger a reconnect and start the reconnect delay timer 278eaf1e85dSHanna Reitz self.stop_nbd_export() 279eaf1e85dSHanna Reitz self.create_nbd_export() 280eaf1e85dSHanna Reitz 281eaf1e85dSHanna Reitz result = self.vm.qmp('human-monitor-command', 282eaf1e85dSHanna Reitz command_line='qemu-io nbd "write 0 512"') 283eaf1e85dSHanna Reitz self.assert_qmp(result, 'return', '') 284eaf1e85dSHanna Reitz 285eaf1e85dSHanna Reitz # Reconnect is done, so the reconnect delay timer should be gone. 286eaf1e85dSHanna Reitz # (This is similar to how the open timer should be gone after open, 287eaf1e85dSHanna Reitz # and similarly there used to be a bug where it was not gone.) 288eaf1e85dSHanna Reitz 289eaf1e85dSHanna Reitz # Delete the BDS to see whether both timers are gone. If they are not, 290eaf1e85dSHanna Reitz # they will remain active, fire later, and then access freed data. 291eaf1e85dSHanna Reitz # (Or, with "block/nbd: Assert there are no timers when closed" 292eaf1e85dSHanna Reitz # applied, the assertions added in that patch will fail.) 293eaf1e85dSHanna Reitz result = self.vm.qmp('blockdev-del', node_name='nbd') 294eaf1e85dSHanna Reitz self.assert_qmp(result, 'return', {}) 295eaf1e85dSHanna Reitz 296eaf1e85dSHanna Reitz # Give the timers some time to fire (both have a timeout of 1 s). 297eaf1e85dSHanna Reitz # (Sleeping in an iotest may ring some alarm bells, but note that if 298eaf1e85dSHanna Reitz # the timing is off here, the test will just always pass. If we kill 299eaf1e85dSHanna Reitz # the VM too early, then we just kill the timers before they can fire, 300eaf1e85dSHanna Reitz # thus not see the error, and so the test will pass.) 301eaf1e85dSHanna Reitz time.sleep(2) 302eaf1e85dSHanna Reitz 303*8cfbe929SHanna Reitz def test_yield_in_iothread(self): 304*8cfbe929SHanna Reitz # Move the NBD node to the I/O thread; the NBD block driver should 305*8cfbe929SHanna Reitz # attach the connection's QIOChannel to that thread's AioContext, too 306*8cfbe929SHanna Reitz result = self.vm.qmp('x-blockdev-set-iothread', 307*8cfbe929SHanna Reitz node_name='nbd', iothread='iothr') 308*8cfbe929SHanna Reitz self.assert_qmp(result, 'return', {}) 309*8cfbe929SHanna Reitz 310*8cfbe929SHanna Reitz # Do some I/O that will be throttled by the QSD, so that the network 311*8cfbe929SHanna Reitz # connection hopefully will yield here. When it is resumed, it must 312*8cfbe929SHanna Reitz # then be resumed in the I/O thread's AioContext. 313*8cfbe929SHanna Reitz result = self.vm.qmp('human-monitor-command', 314*8cfbe929SHanna Reitz command_line='qemu-io nbd "read 0 128K"') 315*8cfbe929SHanna Reitz self.assert_qmp(result, 'return', '') 316*8cfbe929SHanna Reitz 317eaf1e85dSHanna Reitz def create_nbd_export(self): 318eaf1e85dSHanna Reitz assert self.qsd is None 319eaf1e85dSHanna Reitz 320*8cfbe929SHanna Reitz # Export a throttled null-co BDS: Reads are throttled (max 64 kB/s), 321*8cfbe929SHanna Reitz # writes are not. 322eaf1e85dSHanna Reitz self.qsd = QemuStorageDaemon( 323*8cfbe929SHanna Reitz '--object', 324*8cfbe929SHanna Reitz 'throttle-group,id=thrgr,x-bps-read=65536,x-bps-read-max=65536', 325*8cfbe929SHanna Reitz 326eaf1e85dSHanna Reitz '--blockdev', 327eaf1e85dSHanna Reitz 'null-co,node-name=null,read-zeroes=true', 328eaf1e85dSHanna Reitz 329*8cfbe929SHanna Reitz '--blockdev', 330*8cfbe929SHanna Reitz 'throttle,node-name=thr,file=null,throttle-group=thrgr', 331*8cfbe929SHanna Reitz 332eaf1e85dSHanna Reitz '--nbd-server', 333eaf1e85dSHanna Reitz f'addr.type=unix,addr.path={self.sock}', 334eaf1e85dSHanna Reitz 335eaf1e85dSHanna Reitz '--export', 336*8cfbe929SHanna Reitz 'nbd,id=exp,node-name=thr,name=exp,writable=true' 337eaf1e85dSHanna Reitz ) 338eaf1e85dSHanna Reitz 339eaf1e85dSHanna Reitz def stop_nbd_export(self): 340eaf1e85dSHanna Reitz self.qsd.stop() 341eaf1e85dSHanna Reitz self.qsd = None 342eaf1e85dSHanna Reitz 3439b8c59e7SSergio Lopezif __name__ == '__main__': 3449b8c59e7SSergio Lopez iotests.main(supported_fmts=['qcow2'], 345b30b8077SVladimir Sementsov-Ogievskiy supported_protocols=['file'], 346b30b8077SVladimir Sementsov-Ogievskiy unsupported_imgopts=['compat']) 347