CLOUDSTACK-2823: Loop through cmdline when patching routers

Backported from https://reviews.apache.org/r/25585/diff which did not merge
this fix on 4.3 branch. Occasionally the while loop can exit with no data (Probably
 recieving an EOF) before receiveing CMDline data from the certial port.
Continue looping until cmdline is populated

Signed-off-by: Rohit Yadav <rohit.yadav@shapeblue.com>
CLOUDSTACK-7412: Can't create proper template from VM on S3 secondary storage environment

Signed-off-by: Rajani Karuturi <rajanikaruturi@gmail.com>