diff --git a/samples/vboxwrapper/vbox_mscom_impl.cpp b/samples/vboxwrapper/vbox_mscom_impl.cpp index ae7364234d..fb212a6a84 100644 --- a/samples/vboxwrapper/vbox_mscom_impl.cpp +++ b/samples/vboxwrapper/vbox_mscom_impl.cpp @@ -605,25 +605,27 @@ int VBOX_VM::create_vm() { // Add guest additions to the VM // - vboxlog_msg("Adding VirtualBox Guest Additions to VM."); - CComPtr pGuestAdditionsImage; - rc = m_pPrivate->m_pVirtualBox->OpenMedium( - CComBSTR(virtualbox_guest_additions.c_str()), - DeviceType_DVD, - AccessMode_ReadOnly, - FALSE, - &pGuestAdditionsImage - ); - if (CHECK_ERROR(rc)) goto CLEANUP; + if (virtualbox_guest_additions.size()) { + vboxlog_msg("Adding VirtualBox Guest Additions to VM."); + CComPtr pGuestAdditionsImage; + rc = m_pPrivate->m_pVirtualBox->OpenMedium( + CComBSTR(virtualbox_guest_additions.c_str()), + DeviceType_DVD, + AccessMode_ReadOnly, + FALSE, + &pGuestAdditionsImage + ); + if (CHECK_ERROR(rc)) goto CLEANUP; - rc = pMachine->AttachDevice( - CComBSTR("Hard Disk Controller"), - 2, - 0, - DeviceType_DVD, - pGuestAdditionsImage - ); - if (CHECK_ERROR(rc)) goto CLEANUP; + rc = pMachine->AttachDevice( + CComBSTR("Hard Disk Controller"), + 2, + 0, + DeviceType_DVD, + pGuestAdditionsImage + ); + if (CHECK_ERROR(rc)) goto CLEANUP; + } // Add a virtual cache disk drive to VM // @@ -673,25 +675,27 @@ int VBOX_VM::create_vm() { // Add guest additions to the VM // - vboxlog_msg("Adding VirtualBox Guest Additions to VM."); - CComPtr pGuestAdditionsImage; - rc = m_pPrivate->m_pVirtualBox->OpenMedium( - CComBSTR(virtualbox_guest_additions.c_str()), - DeviceType_DVD, - AccessMode_ReadOnly, - FALSE, - &pGuestAdditionsImage - ); - if (CHECK_ERROR(rc)) goto CLEANUP; + if (virtualbox_guest_additions.size()) { + vboxlog_msg("Adding VirtualBox Guest Additions to VM."); + CComPtr pGuestAdditionsImage; + rc = m_pPrivate->m_pVirtualBox->OpenMedium( + CComBSTR(virtualbox_guest_additions.c_str()), + DeviceType_DVD, + AccessMode_ReadOnly, + FALSE, + &pGuestAdditionsImage + ); + if (CHECK_ERROR(rc)) goto CLEANUP; - rc = pMachine->AttachDevice( - CComBSTR("Hard Disk Controller"), - 1, - 0, - DeviceType_DVD, - pGuestAdditionsImage - ); - if (CHECK_ERROR(rc)) goto CLEANUP; + rc = pMachine->AttachDevice( + CComBSTR("Hard Disk Controller"), + 1, + 0, + DeviceType_DVD, + pGuestAdditionsImage + ); + if (CHECK_ERROR(rc)) goto CLEANUP; + } } // Adding virtual floppy disk drive to VM @@ -1935,7 +1939,7 @@ int VBOX_VM::get_version_information(string& version) { } int VBOX_VM::get_guest_additions(string& guest_additions) { - int retval = ERR_EXEC; + int retval = ERR_NOT_FOUND; HRESULT rc; CComPtr properties; CComBSTR tmp; @@ -1945,7 +1949,11 @@ int VBOX_VM::get_guest_additions(string& guest_additions) { rc = properties->get_DefaultAdditionsISO(&tmp); if (SUCCEEDED(rc)) { guest_additions = CW2A(tmp); - retval = BOINC_SUCCESS; + if (!boinc_file_exists(guest_additions.c_str())) { + guest_additions.clear(); + } else { + retval = BOINC_SUCCESS; + } } } diff --git a/samples/vboxwrapper/vbox_vboxmanage.cpp b/samples/vboxwrapper/vbox_vboxmanage.cpp index 4b60982a93..0b6a75d2a8 100644 --- a/samples/vboxwrapper/vbox_vboxmanage.cpp +++ b/samples/vboxwrapper/vbox_vboxmanage.cpp @@ -448,16 +448,18 @@ int VBOX_VM::create_vm() { // Add guest additions to the VM // - vboxlog_msg("Adding VirtualBox Guest Additions to VM."); - 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.size()) { + vboxlog_msg("Adding VirtualBox Guest Additions to VM."); + 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; + retval = vbm_popen(command, output, "storage attach (guest additions image)"); + if (retval) return retval; + } // Add a virtual cache disk drive to VM // @@ -493,16 +495,18 @@ int VBOX_VM::create_vm() { // Add guest additions to the VM // - vboxlog_msg("Adding VirtualBox Guest Additions to VM."); - 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.size()) { + vboxlog_msg("Adding VirtualBox Guest Additions to VM."); + 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; + retval = vbm_popen(command, output, "storage attach (guest additions image)"); + if (retval) return retval; + } } @@ -1514,10 +1518,16 @@ int VBOX_VM::get_guest_additions(string& guest_additions) { ga_end = output.find("\n", ga_start); guest_additions = output.substr(ga_start, ga_end - ga_start); strip_whitespace(guest_additions); + if (guest_additions.size() <= 0) { return ERR_NOT_FOUND; } + if (!boinc_file_exists(guest_additions.c_str())) { + guest_additions.clear(); + return ERR_NOT_FOUND; + } + return retval; }