virttest.utils_test: Add two functions for cdrom attach and eject

Several libvirt cases need attach/eject CDROM, so extract these two common functions here.

Signed-off-by: Yanbing Du <ydu@redhat.com>