Prior to the Huang Chao rebellion communities of foreigners could be found in Guangzhou and apparently Yangzhou. Abu Zayd al-Sirafi gives a rather detailed account of Arab and Chinese trade during the late Tang dynasty. The primary trading port was Guangzhou, known to them as Khanfu. Accord to Zayd, by the time of the destruction of the foreign community in 880 AD there were roughly 120,000 middle easterners there based on Chinese records. Among the various things written by Zayd, here are some of the things he mentioned:
The Tang emperor appointed a Muslim man to deal with Muslims who entered China. This Muslim lead other Muslims in religious activities, particularly Iraqis.
Most of the Persian ships departed from Siraf with goods from Basra and Oman. From Siraf they sailed to Oman, and then Malabar, where the ships are taxed one thousand dirhams, and then the Malay peninsula, Champa, and finally Guangzhou. Guangzhou was and is attractive because it's basically the major port city of southern China. The Arab traveler said that the daily income of Guangzhou's public treasury was 50,000 dinars. When sea merchants reached Guangzhou they were taxed three tenths of their goods.
If a foreigner, or anyone else really, wanted to travel to another part of China they needed to obtain a road permit stating the traveler's name and those accompanying him, their age, and clan. They also needed another document with information on money and goods carried. These were obtained from the government and eunuchs to be checked at guardposts along the road. The guards would then write a report in the following manner:
"So-and so, son of So-and-so, of Such-and-such an origin, arrived at our guardpost on the nth day of the nth month of the nth year, accompanied by So-and-so."
Zayd mentions another Muslim by name, Quraysh in Basra, also known as Ibn Wahb, who was from Basra. After Basra was sacked, he left for Siraf, where he sailed for China. After two months, he arrived in Guangzhou, where he stayed outside the palace gate for some time submitting requests for an audience based on his connections to the family of Muhammad. Eventually he was allowed to stay in a guest house until other Muslims could confirm his kinship with Muhammad, after which he was allowed to visit the emperor of China. They had a conversation about religion and some other stuff, like the ranking of the known world empires, which the emperor listed as Abbasids, China, Turks, India, and Byznatium. Then Ibn Wahb was given a large sum of money which he took back to Iraq.
Source: Two Arabic Travel Books: Accounts of China and India and Mission to the Volga
There's a lot of other information about life in China in general, but not that much as to what life was actually like for an Arab living there. The fact that there were at least 120,000 middle easterners in Guangzhou during the early 9th century probably means they were at least tolerated by the local population though.
TLDR; They lived in Guangzhou or Yangzhou and were probably tolerated by the local population. They obeyed Chinese travel laws and paid taxes on the goods they traded. During the Huang Chao rebellion, Guangzhou was sacked and the middle eastern merchant community of 120,000 (according to Chinese records) was massacred.