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