- 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

svn path=/trunk/boinc/; revision=24822
This commit is contained in:
Rom Walton 2011-12-17 18:10:07 +00:00
parent 83f91025e7
commit d121e6cbb6
2 changed files with 37 additions and 1 deletions

View File

@ -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

View File

@ -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.
//