[libvirt RFCv4 02/20] iohelper: refactor copy operation as a separate function