The cavity in the lung can be an infection as rightly said by the doctor. However infection in cavity can be of bacterial origin as well as tubercular. You need to get sputum studies done for to differentiate it.
However as he is a smoker there is a possibility that it can be a cancer as he has lost weight and had blood in sputum.
I think a Ct scan
of the chest with sputum studies or a bronchoscopy
can give an answer