China’s foreign ministry said on Friday that all sides should exercise restraint following attacks on oil tankers in the Gulf of Oman.