Bug 259234

Summary: emulators/virtualbox-ose proliferation of ~/⋯-VirtualBoxVM-⋯.log files
Product: Ports & Packages Reporter: Graham Perrin <grahamperrin>
Component: Individual Port(s)Assignee: Virtualbox Team (Nobody) <vbox>
Status: New ---    
Severity: Affects Many People CC: madpilot, newton.ja.terry
Priority: --- Flags: bugzilla: maintainer-feedback? (vbox)
Version: Latest   
Hardware: Any   
OS: Any   

Description Graham Perrin 2021-10-17 18:49:11 UTC

> VirtualBox creates small logs in the working directory

Confirmed, at least for ~

% ls ~/*.log | grep -i virtualbox
% pkg info -x virtualbox
% uname -aKU
FreeBSD mowa219-gjp4-8570p-freebsd 14.0-CURRENT FreeBSD 14.0-CURRENT #112 main-n249988-2c614481fd5: Sun Oct 10 21:42:16 BST 2021     root@mowa219-gjp4-8570p-freebsd:/usr/obj/usr/src/amd64.amd64/sys/GENERIC-NODEBUG  amd64 1400036 1400036
% freebsd-version -kru
Comment 1 Graham Perrin 2021-10-21 05:56:03 UTC
From opening post <https://forums.freebsd.org/posts/537276>: 

> … from virtualbox-ose-6.1.22_1 to virtualbox-ose-6.1.26_3. …

If it helps to understand the bug, as it is now: 

* I vaguely recall occasional manual removal of .log files from ~ with 
  _lesser_ versions of VirtualBox. 

There were, in the past, so few that I paid almost zero attention. I did wonder whether they were visible debris, from guest sessions that were abnormally killed. (So little attention, I never thought to browse my home directory _during_ a run of a guest, to tell whether a .log was normally visible during a run.)


As things are now: 

% pkg info -x virtualbox

I see a log file appear immediately after starting, for example, a saved session. 

During the run: 

% date ; cat 2021-10-21-05-50-55.003-VirtualBoxVM-56324.log
Thu 21 Oct 2021 06:55:39 BST
Log created: 2021-10-21T05:50:55.038476000Z
Process ID:  56324 (0xdc04)
Parent PID:  56320 (0xdc00)
Executable:  /usr/local/lib/virtualbox/VirtualBoxVM
Arg[0]: /usr/local/lib/virtualbox/VirtualBoxVM
Arg[1]: --comment
Arg[2]: Windows
Arg[3]: --startvm
Arg[4]: 6bec4796-c6ff-4ebc-8c20-3e56093e1eca
Arg[5]: --no-startvm-errormsgbox
Comment 2 Graham Perrin 2021-10-21 06:43:38 UTC
(In reply to Graham Perrin from comment #1)

> … During the run: …

After graceful closure and save of the guest, followed by a graceful quit of the Oracle VM VirtualBox application: the same. 

(The file persists, nothing appended.)
Comment 3 Guido Falsi freebsd_committer 2021-10-21 07:50:46 UTC
This is a known issue since 6.1.x got in the tree. It was deemed not important enough to not update the port to 6.1.

They are left behind every time a virtual machine is started. Someone (can't remember who) observed they used to be created in the past too, but usually automatically removed if everything went fine with the launched VM.

One thing that could help with this is dig out in the source code where these files are being created.

When debugging such issues a lot of time needs to be spent on finding the involved part of the source code [1], especially when the involved people do not know the structure of the code by hearth. So if you have time to spend on this digging the source code would help more than describing the external behaviour of the software, which is already known.

Also understanding the original purpose of these log files could help.

[1] this is also the reason why good backtraces are so important when any bug arises in any mildly complex software
Comment 4 Graham Perrin 2021-10-21 21:39:08 UTC
Thanks, I'll do what I can (and draw attention in FreeBSD Forums).
Comment 5 Newton Terry 2021-10-23 16:38:22 UTC
(In reply to Guido Falsi from comment #3)
> One thing that could help with this is dig out in the source code where these
> files are being created.
It looks like the involved parts of the source code are to find in 

"Create the default logging instance."

"Write a log header."

I'm not sure how to proceed from here to find the purpose of their creation and the cause of the log files not being removed, assuming they are automatically removed.

Apropos, the creation of those log files can be suppressed by setting VirtualBox env variable "VBOX_LOG_DEST" to "nofile".

Comment 6 Guido Falsi freebsd_committer 2021-10-23 20:27:08 UTC
(In reply to Newton Terry from comment #5)

Thanks for your findings.

So this is the default logging mechanism doing its work. If configured to log a lot of information would be logged to these files.

As far as I know these files have always been created by virtualbox but usually got deleted, maybe right away, depending on..."Something".

But I cannot see any code to remove these files in `src/VBox/Runtime/common/log/log.cpp` or `src/VBox/Runtime/VBox/log-vbox.cpp`. 

So at present I'm asking myself how these got deleted in version 5.2.x.

A quick look at the old distfile or the change history of these files is not helpful unluckily.