VirtualBox

source: vbox/trunk/src/VBox/Frontends/VirtualBox/src/main.cpp@ 35740

Last change on this file since 35740 was 35652, checked in by vboxsync, 13 years ago

VirtualBox --help nit.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 23.0 KB
Line 
1/* $Id: main.cpp 35652 2011-01-20 14:16:38Z vboxsync $ */
2/** @file
3 *
4 * VBox frontends: Qt GUI ("VirtualBox"):
5 * The main() function
6 */
7
8/*
9 * Copyright (C) 2006-2009 Oracle Corporation
10 *
11 * This file is part of VirtualBox Open Source Edition (OSE), as
12 * available from http://www.virtualbox.org. This file is free software;
13 * you can redistribute it and/or modify it under the terms of the GNU
14 * General Public License (GPL) as published by the Free Software
15 * Foundation, in version 2 as it comes in the "COPYING" file of the
16 * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
17 * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
18 */
19
20#ifdef VBOX_WITH_PRECOMPILED_HEADERS
21#include "precomp.h"
22#ifdef Q_WS_MAC
23# include "UICocoaApplication.h"
24#endif /* Q_WS_MAC */
25#else /* !VBOX_WITH_PRECOMPILED_HEADERS */
26#include "VBoxGlobal.h"
27#include "VBoxProblemReporter.h"
28#include "VBoxSelectorWnd.h"
29#include "VBoxUtils.h"
30#ifdef Q_WS_MAC
31# include "UICocoaApplication.h"
32#endif
33
34#ifdef Q_WS_X11
35#include <QFontDatabase>
36#include <iprt/env.h>
37#endif
38
39#include <QCleanlooksStyle>
40#include <QPlastiqueStyle>
41#include <QMessageBox>
42#include <QLocale>
43#include <QTranslator>
44
45#ifdef Q_WS_X11
46# include <X11/Xlib.h>
47#endif
48
49#include <iprt/buildconfig.h>
50#include <iprt/err.h>
51#include <iprt/initterm.h>
52#include <iprt/process.h>
53#include <iprt/stream.h>
54#include <VBox/err.h>
55#include <VBox/version.h>
56#endif /* !VBOX_WITH_PRECOMPILED_HEADERS */
57
58#ifdef VBOX_WITH_HARDENING
59# include <VBox/sup.h>
60#endif
61
62#ifdef RT_OS_LINUX
63# include <unistd.h>
64#endif
65
66#include <cstdio>
67
68/* XXX Temporarily. Don't rely on the user to hack the Makefile himself! */
69QString g_QStrHintLinuxNoMemory = QApplication::tr(
70 "This error means that the kernel driver was either not able to "
71 "allocate enough memory or that some mapping operation failed."
72 );
73
74QString g_QStrHintLinuxNoDriver = QApplication::tr(
75 "The VirtualBox Linux kernel driver (vboxdrv) is either not loaded or "
76 "there is a permission problem with /dev/vboxdrv. Please reinstall the kernel "
77 "module by executing<br/><br/>"
78 " <font color=blue>'/etc/init.d/vboxdrv setup'</font><br/><br/>"
79 "as root. Users of Ubuntu, Fedora or Mandriva should install the DKMS "
80 "package first. This package keeps track of Linux kernel changes and "
81 "recompiles the vboxdrv kernel module if necessary."
82 );
83
84QString g_QStrHintOtherWrongDriverVersion = QApplication::tr(
85 "The VirtualBox kernel modules do not match this version of "
86 "VirtualBox. The installation of VirtualBox was apparently not "
87 "successful. Please try completely uninstalling and reinstalling "
88 "VirtualBox."
89 );
90
91QString g_QStrHintLinuxWrongDriverVersion = QApplication::tr(
92 "The VirtualBox kernel modules do not match this version of "
93 "VirtualBox. The installation of VirtualBox was apparently not "
94 "successful. Executing<br/><br/>"
95 " <font color=blue>'/etc/init.d/vboxdrv setup'</font><br/><br/>"
96 "may correct this. Make sure that you do not mix the "
97 "OSE version and the PUEL version of VirtualBox."
98 );
99
100QString g_QStrHintOtherNoDriver = QApplication::tr(
101 "Make sure the kernel module has been loaded successfully."
102 );
103
104/* I hope this isn't (C), (TM) or (R) Microsoft support ;-) */
105QString g_QStrHintReinstall = QApplication::tr(
106 "Please try reinstalling VirtualBox."
107 );
108
109#if defined(DEBUG) && defined(Q_WS_X11) && defined(RT_OS_LINUX)
110
111#include <signal.h>
112#include <execinfo.h>
113
114/* get REG_EIP from ucontext.h */
115#ifndef __USE_GNU
116#define __USE_GNU
117#endif
118#include <ucontext.h>
119#ifdef RT_ARCH_AMD64
120# define REG_PC REG_RIP
121#else
122# define REG_PC REG_EIP
123#endif
124
125
126
127/**
128 * the signal handler that prints out a backtrace of the call stack.
129 * the code is taken from http://www.linuxjournal.com/article/6391.
130 */
131void bt_sighandler (int sig, siginfo_t *info, void *secret) {
132
133 void *trace[16];
134 char **messages = (char **)NULL;
135 int i, trace_size = 0;
136 ucontext_t *uc = (ucontext_t *)secret;
137
138 /* Do something useful with siginfo_t */
139 if (sig == SIGSEGV)
140 Log (("GUI: Got signal %d, faulty address is %p, from %p\n",
141 sig, info->si_addr, uc->uc_mcontext.gregs[REG_PC]));
142 else
143 Log (("GUI: Got signal %d\n", sig));
144
145 trace_size = backtrace (trace, 16);
146 /* overwrite sigaction with caller's address */
147 trace[1] = (void *) uc->uc_mcontext.gregs [REG_PC];
148
149 messages = backtrace_symbols (trace, trace_size);
150 /* skip first stack frame (points here) */
151 Log (("GUI: [bt] Execution path:\n"));
152 for (i = 1; i < trace_size; ++i)
153 Log (("GUI: [bt] %s\n", messages[i]));
154
155 exit (0);
156}
157
158#endif /* DEBUG && X11 && LINUX*/
159
160#if defined(RT_OS_DARWIN)
161# include <dlfcn.h>
162# include <sys/mman.h>
163# include <iprt/asm.h>
164# include <iprt/system.h>
165
166/** Really ugly hack to shut up a silly check in AppKit. */
167static void ShutUpAppKit(void)
168{
169 /* Check for Snow Leopard or higher */
170 char szInfo[64];
171 int rc = RTSystemQueryOSInfo (RTSYSOSINFO_RELEASE, szInfo, sizeof(szInfo));
172 if (RT_SUCCESS (rc) &&
173 szInfo[0] == '1') /* higher than 1x.x.x */
174 {
175 /*
176 * Find issetguid() and make it always return 0 by modifying the code.
177 */
178 void *addr = dlsym(RTLD_DEFAULT, "issetugid");
179 int rc = mprotect((void *)((uintptr_t)addr & ~(uintptr_t)0xfff), 0x2000, PROT_WRITE|PROT_READ|PROT_EXEC);
180 if (!rc)
181 ASMAtomicWriteU32((volatile uint32_t *)addr, 0xccc3c031); /* xor eax, eax; ret; int3 */
182 }
183}
184#endif /* DARWIN */
185
186static void QtMessageOutput (QtMsgType type, const char *msg)
187{
188#ifndef Q_WS_X11
189 NOREF(msg);
190#endif
191 switch (type)
192 {
193 case QtDebugMsg:
194 Log (("Qt DEBUG: %s\n", msg));
195 break;
196 case QtWarningMsg:
197 Log (("Qt WARNING: %s\n", msg));
198#ifdef Q_WS_X11
199 /* Needed for instance for the message ``cannot connect to X server'' */
200 RTStrmPrintf(g_pStdErr, "Qt WARNING: %s\n", msg);
201#endif
202 break;
203 case QtCriticalMsg:
204 Log (("Qt CRITICAL: %s\n", msg));
205#ifdef Q_WS_X11
206 /* Needed for instance for the message ``cannot connect to X server'' */
207 RTStrmPrintf(g_pStdErr, "Qt CRITICAL: %s\n", msg);
208#endif
209 break;
210 case QtFatalMsg:
211 Log (("Qt FATAL: %s\n", msg));
212#ifdef Q_WS_X11
213 RTStrmPrintf(g_pStdErr, "Qt FATAL: %s\n", msg);
214#endif
215 }
216}
217
218/**
219 * Show all available command line parameters.
220 */
221static void showHelp()
222{
223 QString mode = "", dflt = "";
224#ifdef VBOX_GUI_USE_SDL
225 mode += "sdl";
226#endif
227#ifdef VBOX_GUI_USE_QIMAGE
228 if (!mode.isEmpty())
229 mode += "|";
230 mode += "image";
231#endif
232#ifdef VBOX_GUI_USE_DDRAW
233 if (!mode.isEmpty())
234 mode += "|";
235 mode += "ddraw";
236#endif
237#ifdef VBOX_GUI_USE_QUARTZ2D
238 if (!mode.isEmpty())
239 mode += "|";
240 mode += "quartz2d";
241#endif
242#if defined (Q_WS_MAC) && defined (VBOX_GUI_USE_QUARTZ2D)
243 dflt = "quartz2d";
244#elif (defined (Q_WS_WIN32) || defined (Q_WS_PM)) && defined (VBOX_GUI_USE_QIMAGE)
245 dflt = "image";
246#elif defined (Q_WS_X11) && defined (VBOX_GUI_USE_SDL)
247 dflt = "sdl";
248#else
249 dflt = "image";
250#endif
251
252 RTPrintf(VBOX_PRODUCT " Manager %s\n"
253 "(C) 2005-" VBOX_C_YEAR " " VBOX_VENDOR "\n"
254 "All rights reserved.\n"
255 "\n"
256 "Usage:\n"
257 " --startvm <vmname|UUID> start a VM by specifying its UUID or name\n"
258 " --seamless switch to seamless mode during startup\n"
259 " --fullscreen switch to fullscreen mode during startup\n"
260 " --rmode %-18s select different render mode (default is %s)\n"
261 " --no-startvm-errormsgbox do not show a message box for VM start errors\n"
262# ifdef VBOX_GUI_WITH_PIDFILE
263 " --pidfile <file> create a pidfile file when a VM is up and running\n"
264# endif
265# ifdef VBOX_WITH_DEBUGGER_GUI
266 " --dbg enable the GUI debug menu\n"
267 " --debug like --dbg and show debug windows at VM startup\n"
268 " --debug-command-line like --dbg and show command line window at VM startup\n"
269 " --debug-statistics like --dbg and show statistics window at VM startup\n"
270 " --no-debug disable the GUI debug menu and debug windows\n"
271 " --start-paused start the VM in the paused state\n"
272 " --start-running start the VM running (for overriding --debug*)\n"
273 "\n"
274 "The following environment variables are evaluated:\n"
275 " VBOX_GUI_DBG_ENABLED enable the GUI debug menu if set\n"
276 " VBOX_GUI_DBG_AUTO_SHOW show debug windows at VM startup\n"
277 " VBOX_GUI_NO_DEBUGGER disable the GUI debug menu and debug windows\n"
278# endif
279 "\n",
280 RTBldCfgVersion(),
281 mode.toLatin1().constData(),
282 dflt.toLatin1().constData());
283 /** @todo Show this as a dialog on windows. */
284}
285
286extern "C" DECLEXPORT(int) TrustedMain (int argc, char **argv, char ** /*envp*/)
287{
288 LogFlowFuncEnter();
289# if defined(RT_OS_DARWIN)
290 ShutUpAppKit();
291# endif
292
293 for (int i=0; i<argc; i++)
294 if ( !strcmp(argv[i], "-h")
295 || !strcmp(argv[i], "-?")
296 || !strcmp(argv[i], "-help")
297 || !strcmp(argv[i], "--help"))
298 {
299 showHelp();
300 return 0;
301 }
302
303#if defined(DEBUG) && defined(Q_WS_X11) && defined(RT_OS_LINUX)
304 /* install our signal handler to backtrace the call stack */
305 struct sigaction sa;
306 sa.sa_sigaction = bt_sighandler;
307 sigemptyset (&sa.sa_mask);
308 sa.sa_flags = SA_RESTART | SA_SIGINFO;
309 sigaction (SIGSEGV, &sa, NULL);
310 sigaction (SIGBUS, &sa, NULL);
311 sigaction (SIGUSR1, &sa, NULL);
312#endif
313
314#ifdef QT_MAC_USE_COCOA
315 /* Instantiate our NSApplication derivative before QApplication
316 * forces NSApplication to be instantiated. */
317 UICocoaApplication::instance();
318#endif
319
320 qInstallMsgHandler (QtMessageOutput);
321
322 int rc = 1; /* failure */
323
324 /* scope the QApplication variable */
325 {
326#ifdef Q_WS_X11
327 /* Qt has a complex algorithm for selecting the right visual which
328 * doesn't always seem to work. So we naively choose a visual - the
329 * default one - ourselves and pass that to Qt. This means that we
330 * also have to open the display ourselves.
331 * We check the Qt parameter list and handle Qt's -display argument
332 * ourselves, since we open the display connection. We also check the
333 * to see if the user has passed Qt's -visual parameter, and if so we
334 * assume that the user wants Qt to handle visual selection after all,
335 * and don't supply a visual. */
336 char *pszDisplay = NULL;
337 bool useDefaultVisual = true;
338 for (int i = 0; i < argc; ++i)
339 {
340 if (!::strcmp(argv[i], "-display") && (i + 1 < argc))
341 /* What if it isn't? Rely on QApplication to complain? */
342 {
343 pszDisplay = argv[i + 1];
344 ++i;
345 }
346 else if (!::strcmp(argv[i], "-visual"))
347 useDefaultVisual = false;
348 }
349 Display *pDisplay = XOpenDisplay(pszDisplay);
350 if (!pDisplay)
351 {
352 RTPrintf(pszDisplay ? "Failed to open the X11 display \"%s\"!\n"
353 : "Failed to open the X11 display!\n",
354 pszDisplay);
355 return 0;
356 }
357 Visual *pVisual = useDefaultVisual
358 ? DefaultVisual(pDisplay, DefaultScreen(pDisplay))
359 : NULL;
360 /* Now create the application object */
361 QApplication a (pDisplay, argc, argv, (Qt::HANDLE) pVisual);
362#else /* Q_WS_X11 */
363 QApplication a (argc, argv);
364#endif /* Q_WS_X11 */
365
366 /* Qt4.3 version has the QProcess bug which freezing the application
367 * for 30 seconds. This bug is internally used at initialization of
368 * Cleanlooks style. So we have to change this style to another one.
369 * See http://trolltech.com/developer/task-tracker/index_html?id=179200&method=entry
370 * for details. */
371 if (VBoxGlobal::qtRTVersionString().startsWith ("4.3") &&
372 qobject_cast <QCleanlooksStyle*> (QApplication::style()))
373 QApplication::setStyle (new QPlastiqueStyle);
374
375#ifdef Q_OS_SOLARIS
376 /* Solaris have some issue with cleanlooks style which leads to application
377 * crash in case of using it on Qt4.4 version, lets make the same substitute */
378 if (VBoxGlobal::qtRTVersionString().startsWith ("4.4") &&
379 qobject_cast <QCleanlooksStyle*> (QApplication::style()))
380 QApplication::setStyle (new QPlastiqueStyle);
381#endif
382
383#ifdef Q_WS_X11
384 /* This patch is not used for now on Solaris & OpenSolaris because
385 * there is no anti-aliasing enabled by default, Qt4 to be rebuilt. */
386#ifndef Q_OS_SOLARIS
387 /* Cause Qt4 has the conflict with fontconfig application as a result
388 * sometimes substituting some fonts with non scaleable-anti-aliased
389 * bitmap font we are reseting substitutes for the current application
390 * font family if it is non scaleable-anti-aliased. */
391 QFontDatabase fontDataBase;
392
393 QString currentFamily (QApplication::font().family());
394 bool isCurrentScaleable = fontDataBase.isScalable (currentFamily);
395
396 /*
397 LogFlowFunc (("Font: Current family is '%s'. It is %s.\n",
398 currentFamily.toLatin1().constData(),
399 isCurrentScaleable ? "scalable" : "not scalable"));
400 QStringList subFamilies (QFont::substitutes (currentFamily));
401 foreach (QString sub, subFamilies)
402 {
403 bool isSubScalable = fontDataBase.isScalable (sub);
404 LogFlowFunc (("Font: Substitute family is '%s'. It is %s.\n",
405 sub.toLatin1().constData(),
406 isSubScalable ? "scalable" : "not scalable"));
407 }
408 */
409
410 QString subFamily (QFont::substitute (currentFamily));
411 bool isSubScaleable = fontDataBase.isScalable (subFamily);
412
413 if (isCurrentScaleable && !isSubScaleable)
414 QFont::removeSubstitution (currentFamily);
415#endif /* Q_OS_SOLARIS */
416#endif
417
418#ifdef Q_WS_WIN
419 /* Drag in the sound drivers and DLLs early to get rid of the delay taking
420 * place when the main menu bar (or any action from that menu bar) is
421 * activated for the first time. This delay is especially annoying if it
422 * happens when the VM is executing in real mode (which gives 100% CPU
423 * load and slows down the load process that happens on the main GUI
424 * thread to several seconds). */
425 PlaySound (NULL, NULL, 0);
426#endif
427
428#ifdef Q_WS_MAC
429 ::darwinDisableIconsInMenus();
430#endif /* Q_WS_MAC */
431
432#ifdef Q_WS_X11
433 /* version check (major.minor are sensitive, fix number is ignored) */
434 if (VBoxGlobal::qtRTVersion() < (VBoxGlobal::qtCTVersion() & 0xFFFF00))
435 {
436 QString msg =
437 QApplication::tr ("Executable <b>%1</b> requires Qt %2.x, found Qt %3.")
438 .arg (qAppName())
439 .arg (VBoxGlobal::qtCTVersionString().section ('.', 0, 1))
440 .arg (VBoxGlobal::qtRTVersionString());
441 QMessageBox::critical (
442 0, QApplication::tr ("Incompatible Qt Library Error"),
443 msg, QMessageBox::Abort, 0);
444 qFatal ("%s", msg.toAscii().constData());
445 }
446#endif
447
448 /* load a translation based on the current locale */
449 VBoxGlobal::loadLanguage();
450
451 do
452 {
453 if (!vboxGlobal().isValid())
454 break;
455
456
457 if (vboxGlobal().processArgs())
458 return 0;
459
460 vboxProblem().checkForMountedWrongUSB();
461
462 VBoxGlobalSettings settings = vboxGlobal().settings();
463 /* Process known keys */
464 bool noSelector = settings.isFeatureActive ("noSelector");
465
466 if (vboxGlobal().isVMConsoleProcess())
467 {
468#ifdef VBOX_GUI_WITH_SYSTRAY
469 if (vboxGlobal().trayIconInstall())
470 {
471 /* Nothing to do here yet. */
472 }
473#endif
474 if (vboxGlobal().startMachine (vboxGlobal().managedVMUuid()))
475 {
476 vboxGlobal().setMainWindow (vboxGlobal().vmWindow());
477 rc = a.exec();
478 }
479 }
480 else if (noSelector)
481 {
482 vboxProblem().cannotRunInSelectorMode();
483 }
484 else
485 {
486#ifdef VBOX_BLEEDING_EDGE
487 vboxProblem().showBEBWarning();
488#else
489# ifndef DEBUG
490 /* Check for BETA version */
491 QString vboxVersion (vboxGlobal().virtualBox().GetVersion());
492 if (vboxVersion.contains ("BETA"))
493 {
494 /* Allow to prevent this message */
495 QString str = vboxGlobal().virtualBox().
496 GetExtraData (VBoxDefs::GUI_PreventBetaWarning);
497 if (str != vboxVersion)
498 vboxProblem().showBETAWarning();
499 }
500# endif
501#endif
502
503 vboxGlobal().setMainWindow (&vboxGlobal().selectorWnd());
504#ifdef VBOX_GUI_WITH_SYSTRAY
505 if (vboxGlobal().trayIconInstall())
506 {
507 /* Nothing to do here yet. */
508 }
509
510 if (false == vboxGlobal().isTrayMenu())
511 {
512#endif
513 vboxGlobal().selectorWnd().show();
514#ifdef VBOX_WITH_REGISTRATION_REQUEST
515 vboxGlobal().showRegistrationDialog (false /* aForce */);
516#endif
517#ifdef VBOX_WITH_UPDATE_REQUEST
518 vboxGlobal().showUpdateDialog (false /* aForce */);
519#endif
520#ifdef VBOX_GUI_WITH_SYSTRAY
521 }
522
523 do
524 {
525#endif
526 rc = a.exec();
527#ifdef VBOX_GUI_WITH_SYSTRAY
528 } while (vboxGlobal().isTrayMenu());
529#endif
530 }
531 }
532 while (0);
533 }
534
535 LogFlowFunc (("rc=%d\n", rc));
536 LogFlowFuncLeave();
537
538 return rc;
539}
540
541#ifndef VBOX_WITH_HARDENING
542
543int main (int argc, char **argv, char **envp)
544{
545 /* Initialize VBox Runtime. Initialize the SUPLib as well only if we
546 * are really about to start a VM. Don't do this if we are only starting
547 * the selector window. */
548 bool fInitSUPLib = false;
549 for (int i = 1; i < argc; i++)
550 {
551 /* NOTE: the check here must match the corresponding check for the
552 * options to start a VM in hardenedmain.cpp and VBoxGlobal.cpp exactly,
553 * otherwise there will be weird error messages. */
554 if ( !::strcmp(argv[i], "--startvm")
555 || !::strcmp(argv[i], "-startvm"))
556 {
557 fInitSUPLib = true;
558 break;
559 }
560 }
561
562 int rc;
563 if (!fInitSUPLib)
564 rc = RTR3Init();
565 else
566 rc = RTR3InitAndSUPLib();
567 if (RT_FAILURE(rc))
568 {
569 QApplication a (argc, &argv[0]);
570#ifdef Q_OS_SOLARIS
571 /* Solaris have some issue with cleanlooks style which leads to application
572 * crash in case of using it on Qt4.4 version, lets make the same substitute */
573 if (VBoxGlobal::qtRTVersionString().startsWith ("4.4") &&
574 qobject_cast <QCleanlooksStyle*> (QApplication::style()))
575 QApplication::setStyle (new QPlastiqueStyle);
576#endif
577 QString msgTitle = QApplication::tr ("VirtualBox - Runtime Error");
578 QString msgText = "<html>";
579
580 switch (rc)
581 {
582 case VERR_VM_DRIVER_NOT_INSTALLED:
583 msgText += QApplication::tr (
584 "<b>Cannot access the kernel driver!</b><br/><br/>");
585# ifdef RT_OS_LINUX
586 msgText += g_QStrHintLinuxNoDriver;
587# else
588 msgText += g_QStrHintOtherNoDriver;
589# endif
590 break;
591# ifdef RT_OS_LINUX
592 case VERR_NO_MEMORY:
593 msgText += g_QStrHintLinuxNoMemory;
594 break;
595# endif
596 case VERR_VM_DRIVER_NOT_ACCESSIBLE:
597 msgText += QApplication::tr ("Kernel driver not accessible");
598 break;
599 case VERR_VM_DRIVER_VERSION_MISMATCH:
600# ifdef RT_OS_LINUX
601 msgText += g_QStrHintLinuxWrongDriverVersion;
602# else
603 msgText += g_QStrHintOtherWrongDriverVersion;
604# endif
605 break;
606 default:
607 msgText += QApplication::tr (
608 "Unknown error %2 during initialization of the Runtime"
609 ).arg (rc);
610 break;
611 }
612 msgText += "</html>";
613 QMessageBox::critical (
614 0, /* parent */
615 msgTitle,
616 msgText,
617 QMessageBox::Abort, /* button0 */
618 0); /* button1 */
619 return 1;
620 }
621
622 return TrustedMain (argc, argv, envp);
623}
624
625#else /* VBOX_WITH_HARDENING */
626
627/**
628 * Hardened main failed, report the error without any unnecessary fuzz.
629 *
630 * @remarks Do not call IPRT here unless really required, it might not be
631 * initialized.
632 */
633extern "C" DECLEXPORT(void) TrustedError (const char *pszWhere, SUPINITOP enmWhat, int rc, const char *pszMsgFmt, va_list va)
634{
635# if defined(RT_OS_DARWIN)
636 ShutUpAppKit();
637# endif
638
639 /*
640 * Init the Qt application object. This is a bit hackish as we
641 * don't have the argument vector handy.
642 */
643 int argc = 0;
644 char *argv[2] = { NULL, NULL };
645 QApplication a (argc, &argv[0]);
646
647 /*
648 * Compose and show the error message.
649 */
650 QString msgTitle = QApplication::tr ("VirtualBox - Error In %1").arg (pszWhere);
651
652 char msgBuf[1024];
653 vsprintf (msgBuf, pszMsgFmt, va);
654
655 QString msgText = QApplication::tr (
656 "<html><b>%1 (rc=%2)</b><br/><br/>").arg (msgBuf).arg (rc);
657 switch (enmWhat)
658 {
659 case kSupInitOp_Driver:
660# ifdef RT_OS_LINUX
661 msgText += g_QStrHintLinuxNoDriver;
662# else
663 msgText += g_QStrHintOtherNoDriver;
664# endif
665 break;
666# ifdef RT_OS_LINUX
667 case kSupInitOp_IPRT:
668 if (rc == VERR_NO_MEMORY)
669 msgText += g_QStrHintLinuxNoMemory;
670 else
671# endif
672 if (rc == VERR_VM_DRIVER_VERSION_MISMATCH)
673# ifdef RT_OS_LINUX
674 msgText += g_QStrHintLinuxWrongDriverVersion;
675# else
676 msgText += g_QStrHintOtherWrongDriverVersion;
677# endif
678 else
679 msgText += g_QStrHintReinstall;
680 break;
681 case kSupInitOp_Integrity:
682 case kSupInitOp_RootCheck:
683 msgText += g_QStrHintReinstall;
684 break;
685 default:
686 /* no hints here */
687 break;
688 }
689 msgText += "</html>";
690
691# ifdef RT_OS_LINUX
692 sleep(2);
693# endif
694 QMessageBox::critical (
695 0, /* parent */
696 msgTitle, /* title */
697 msgText, /* text */
698 QMessageBox::Abort, /* button0 */
699 0); /* button1 */
700 qFatal ("%s", msgText.toAscii().constData());
701}
702
703#endif /* VBOX_WITH_HARDENING */
704
Note: See TracBrowser for help on using the repository browser.

© 2023 Oracle
ContactPrivacy policyTerms of Use