A simpler way is just to add the serial=1234 or whatever to the .conf file for your VM. Make sure you power cycle (not a simple reboot) the VM to reset the value.
Example:
bootdisk: virtio0
cores: 1
ide0: VMStorage:101/vm-101-disk-2.qcow2,cache=writethrough,size=50G,serial=1234
ide1...