diff --git a/samples/vboxwrapper/vbox.cpp b/samples/vboxwrapper/vbox.cpp index 85c7ddbbda..9dca1c7071 100644 --- a/samples/vboxwrapper/vbox.cpp +++ b/samples/vboxwrapper/vbox.cpp @@ -226,8 +226,7 @@ int VBOX_VM::initialize() { rc = get_version_information(virtualbox_version); if (rc) return rc; - rc = get_guest_additions(virtualbox_guest_additions); - if (rc) return rc; + get_guest_additions(virtualbox_guest_additions); return 0; } @@ -770,22 +769,26 @@ int VBOX_VM::create_vm() { retval = vbm_popen(command, output, "storage attach (ISO 9660 image)"); if (retval) return retval; - // Add guest additions to the VM - // - fprintf( - stderr, - "%s Adding VirtualBox Guest Additions to VM.\n", - vboxwrapper_msg_prefix(buf, sizeof(buf)) - ); - command = "storageattach \"" + vm_name + "\" "; - command += "--storagectl \"Hard Disk Controller\" "; - command += "--port 2 "; - command += "--device 0 "; - command += "--type dvddrive "; - command += "--medium \"" + virtualbox_guest_additions + "\" "; + if (!virtualbox_guest_additions.empty()) { - retval = vbm_popen(command, output, "storage attach (guest additions image)"); - if (retval) return retval; + // Add guest additions to the VM + // + fprintf( + stderr, + "%s Adding VirtualBox Guest Additions to VM.\n", + vboxwrapper_msg_prefix(buf, sizeof(buf)) + ); + command = "storageattach \"" + vm_name + "\" "; + command += "--storagectl \"Hard Disk Controller\" "; + command += "--port 2 "; + command += "--device 0 "; + command += "--type dvddrive "; + command += "--medium \"" + virtualbox_guest_additions + "\" "; + + retval = vbm_popen(command, output, "storage attach (guest additions image)"); + if (retval) return retval; + + } // Add a virtual cache disk drive to VM // @@ -829,22 +832,26 @@ int VBOX_VM::create_vm() { retval = vbm_popen(command, output, "storage attach (fixed disk)"); if (retval) return retval; - // Add guest additions to the VM - // - fprintf( - stderr, - "%s Adding VirtualBox Guest Additions to VM.\n", - vboxwrapper_msg_prefix(buf, sizeof(buf)) - ); - command = "storageattach \"" + vm_name + "\" "; - command += "--storagectl \"Hard Disk Controller\" "; - command += "--port 1 "; - command += "--device 0 "; - command += "--type dvddrive "; - command += "--medium \"" + virtualbox_guest_additions + "\" "; + if (!virtualbox_guest_additions.empty()) { - retval = vbm_popen(command, output, "storage attach (guest additions image)"); - if (retval) return retval; + // Add guest additions to the VM + // + fprintf( + stderr, + "%s Adding VirtualBox Guest Additions to VM.\n", + vboxwrapper_msg_prefix(buf, sizeof(buf)) + ); + command = "storageattach \"" + vm_name + "\" "; + command += "--storagectl \"Hard Disk Controller\" "; + command += "--port 1 "; + command += "--device 0 "; + command += "--type dvddrive "; + command += "--medium \"" + virtualbox_guest_additions + "\" "; + + retval = vbm_popen(command, output, "storage attach (guest additions image)"); + if (retval) return retval; + + } }