From Kunming, China, you can apply for a visa to Vietnam: either visiting Vietnamese Consulate or apply for a cost effective visa on arrival.
Visa on arrival - Visa at embassy comparison chart

Visiting Vietnam consulate in Kunming
The cost is around 400 RMB (~US$50), single 1 month, and issued in 3 days.
Vietnam visa fee
- Y400 4 days (30 days)
- Y600 same day (30days)
Vietnamese Embassy, Kunming Consulate:
Add: 2nd floor, Kai Wah International Hotel, 157 Beijing Lu, Kunming
Tel: 86-871-3522669/3515889 ; Fax: 86-871-3516667
Email: tlsqcm@yahoo.com
You may also apply for a convenient visa on arrival without visiting an embassy or sending off your passport.
How to get there to Hanoi from Kunming, China
By train & bus
Train is no longer operated due to landslides. However, a daily bus takes over 10 hours and costs less than US$24, but the condition of the bus is not good.
By air
Vietnam airlines operates flights from Kunming to Hanoi. A one-way Kunming - Hanoi plane ticket on Vietnam Airlines, cost about 2800 RMB inclusive of taxes.
Related reading
Getting Vietnam visa in China
Getting Vietnam visa in Beijing
Getting Vietnam visa in Shanghai
Getting Vietnam visa in Guangzhou
Getting Vietnam visa in Hong Kong

