My question involves search and seizure law in the State of: Virginia

Last night around 6:30pm an officer knocked on my door explaining that he was here for a burglary upstairs in our complex and that he just had a few questions for me. So i answered his questions and he asked me to come out in the hall. So i did. He explained to me that my apartment smelled like "cheech and Chong" and he asked me if i had any MJ in the house. At first i told him no. And he explained that he could (if necissary) get another officer to come stay with me while he went and got a warrent to search the apartment and he could call social services to come get my daughter. After he explained what all COULD happen he told me that if i complied with him that the above would not happen. So i was honest with him and turned everything over to the cops and let them search because i had nothing else to hide. They then had 2 other detectives come in and take pictures of every room they searched. and now i'm facing 2 felony charges.

I just wanna know, did he have any right to question me about the MJ and go about doing what he did based on what he "smelled" from outside, when he was originally here for something ELSE that didnt even involve me?