diff --git a/checkin_notes b/checkin_notes
index 114da8938e..3c2f06b84f 100644
--- a/checkin_notes
+++ b/checkin_notes
@@ -9278,4 +9278,11 @@ Rom 21 Dec 2011
samples/vboxwrapper/
vbox.cpp
-
\ No newline at end of file
+
+Rom 21 Dec 2011
+ - VBOX: It turns out that once you set the firewall rules, you cannot reset the
+ rules for a VM until the VM is in a powered off state. I guess the VM will
+ just have to fail starting up if it cannot allocate the assigned port.
+
+ samples/vboxwrapper/
+ vbox.cpp
diff --git a/samples/vboxwrapper/vbox.cpp b/samples/vboxwrapper/vbox.cpp
index 4a89a2d237..a557226c9d 100644
--- a/samples/vboxwrapper/vbox.cpp
+++ b/samples/vboxwrapper/vbox.cpp
@@ -100,13 +100,6 @@ int VBOX_VM::run() {
// error to stop further processing.
if (register_only) return ERR_FOPEN;
- // If a project wants to open up a firewall port through the VirtualBox virtual
- // network firewall/nat do that here. This has to be done for every execution
- // of the wrapper because available host ports change depending on what other
- // software is running.
- retval = register_vm_firewall_rules();
- if (retval) return retval;
-
retval = start();
if (retval) return retval;
@@ -641,6 +634,14 @@ int VBOX_VM::register_vm() {
set_network_access(true);
}
+ // If a project wants to open up a firewall port through the VirtualBox virtual
+ // network firewall/nat do that here.
+ //
+ if (pf_desired_host_port) {
+ retval = register_vm_firewall_rules();
+ if (retval) return retval;
+ }
+
// Enable the shared folder if a shared folder is specified.
//
if (enable_shared_directory) {
@@ -670,19 +671,12 @@ int VBOX_VM::register_vm_firewall_rules() {
int sock;
int retval;
- // Are we being requested to open a firewall port? if the desired
- // guest port is zero, then no. The desired host port can be zero
- // which means the OS should dynamically assign one.
- //
- if (pf_desired_guest_port == 0) return 0;
-
get_slot_directory(virtual_machine_slot_directory);
fprintf(
stderr,
- "%s Registering virtual machine firewall rules. (%s)\n",
- boinc_msg_prefix(buf, sizeof(buf)),
- vm_name.c_str()
+ "%s Registering virtual machine firewall rules.\n",
+ boinc_msg_prefix(buf, sizeof(buf))
);
memset(&addr, 0, sizeof(addr));
@@ -721,13 +715,6 @@ int VBOX_VM::register_vm_firewall_rules() {
boinc_close_socket(sock);
- // Remove any stale firewall rule
- //
- command = "modifyvm \"" + vm_name + "\" ";
- command += "--natpf1 delete \"vboxwrapper\" ";
-
- vbm_popen(command, output, "remove stale port forwarding rule");
-
// Add new firewall rule
//
sprintf(buf, "vboxwrapper,tcp,127.0.0.1,%d,,%d", pf_assigned_host_port, pf_desired_guest_port);
diff --git a/win_build/vboxwrapper.vcproj b/win_build/vboxwrapper.vcproj
index e6f0fb5243..5972186321 100644
--- a/win_build/vboxwrapper.vcproj
+++ b/win_build/vboxwrapper.vcproj
@@ -81,13 +81,13 @@
@@ -182,13 +182,13 @@