Installing CentOS Linux in a virtual machine with VirtualBox is a straightforward exercise. The exception comes when configuring Guest Editions on the operating system. I find it easiest to use a group install with Yum, before “inserting” the disc for Guest Editions. Using the following two lines in the shell will ensure that the C compiler and kernel are available for installing Guest Editions.
sudo yum groups install 'Development Tools'
sudo yum install kernel-devel-yourLatestVersion
Further guidance is available in the user manual. https://www.virtualbox.org/manual/UserManual.html#externalkernelmodules