Skip to content

Commit

Permalink
Floppy random name based on time. Close #38
Browse files Browse the repository at this point in the history
The floppy name is generated using the time since EPOCH as a tag to avoid
floppy registration errors.
  • Loading branch information
teleyinex committed Aug 13, 2012
1 parent 4f79cd4 commit 5a863d3
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 4 deletions.
2 changes: 1 addition & 1 deletion cernvm-wrapper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,7 @@ int main(int argc, char** argv)
else {
cerr << "VM exists, starting it..." << endl;
}

time_t elapsed_secs = 0;
long int t = 0;
double frac_done = 0, dif_secs = 0;
Expand Down
17 changes: 14 additions & 3 deletions vbox.h
Original file line number Diff line number Diff line change
Expand Up @@ -282,7 +282,18 @@ void VM::create()
}

// Create the controller for the virtual floppy image
FloppyIO floppy("floppy.img");
unsigned long int slug = time(NULL);
string floppy_name;
std::stringstream out;
out << "floppy_" << slug << ".img";
floppy_name = out.str();
// Save the name of the floppy
ofstream myfile;
myfile.open("FloppyName.txt");
myfile << floppy_name << endl;
myfile.close();
// Create the Floppy image
FloppyIO floppy(floppy_name.c_str());
arg_list.clear();
arg_list = "storagectl " + virtual_machine_name + \
" --name \"Floppy Controller\" --add floppy";
Expand All @@ -292,7 +303,7 @@ void VM::create()
arg_list.clear();
arg_list = "storageattach " + virtual_machine_name + \
" --storagectl \"Floppy Controller\" \
--port 0 --device 0 --medium floppy.img";
--port 0 --device 0 --medium " + floppy_name.c_str();

if (!vbm_popen(arg_list)) {
cerr << "ERROR: Adding the Floppy image failed! Aborting" << endl;
Expand Down Expand Up @@ -658,7 +669,7 @@ void VM::remove()

// Wait to allow to discard the VM state cleanly
boinc_sleep(2);

// Unregistervm command with --delete option. VBox 4.1 should work well
arg_list.clear();
arg_list = " unregistervm " + virtual_machine_name + " --delete";
Expand Down

0 comments on commit 5a863d3

Please sign in to comment.