[libvirt RFCv7 02/40] iohelper: refactor copy operation as a separate function