x86: qemu: Extract getting memory size to a separate routine