diff --git a/checkin_notes b/checkin_notes index 195d4a9ee1..de1bc01454 100644 --- a/checkin_notes +++ b/checkin_notes @@ -9094,3 +9094,13 @@ David 16 Dec 2011 client/ pers_file_xfer.cpp file_xfer.cpp + +Rom 17 Dec 2011 + - VBOX: Attempt to detect the condition where a Virtual HD image has already been + registered with VirtualBox during the RegisterVM phase. If we detect the + already exists error message run the unsupported internal command to reset + the HD UUID which then allows us to attach the HD to the VM. This should allow + us to run multiple jobs with the same base VM HD image. + + samples/vboxwrapper/ + vbox.cpp diff --git a/samples/vboxwrapper/vbox.cpp b/samples/vboxwrapper/vbox.cpp index a0698277a3..994c21a6fe 100644 --- a/samples/vboxwrapper/vbox.cpp +++ b/samples/vboxwrapper/vbox.cpp @@ -541,7 +541,33 @@ int VBOX_VM::register_vm() { command += "--medium \"" + virtual_machine_slot_directory + "/" + image_filename + "\" "; retval = vbm_popen(command, output, "storage attach"); - if (retval) return retval; + if (retval) { + // Is this an error condition we know how to handle? + + // Check to see if the Virtual HD UUID needs to be reset + if ((output.find("E_INVALIDARG") != string::npos) && (output.find("already exists") != string::npos)) { + + command = "internalcommands "; + command += "sethduuid \"" + virtual_machine_slot_directory + "/" + image_filename + "\" "; + + retval = vbm_popen(command, output, "sethduuid"); + if (retval) return retval; + + // Now lets try to attach the Virtual HD + command = "storageattach \"" + vm_name + "\" "; + command += "--storagectl \"IDE Controller\" "; + command += "--port 0 "; + command += "--device 0 "; + command += "--type hdd "; + command += "--medium \"" + virtual_machine_slot_directory + "/" + image_filename + "\" "; + + retval = vbm_popen(command, output, "storage attach"); + if (retval) return retval; + + } else { + return retval; + } + } // Enable the network adapter if a network connection is required. //