[libvirt RFCv5 02/27] iohelper: refactor copy operation as a separate function