Changeset 105547 in vbox for trunk/src/VBox/Frontends/VirtualBox
- Timestamp:
- Jul 31, 2024 12:36:41 AM (7 months ago)
- svn:sync-xref-src-repo-rev:
- 164218
- Location:
- trunk/src/VBox/Frontends/VirtualBox/src
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VirtualBox/src/globals/UICommon.cpp
r105546 r105547 315 315 const char *arg = argBytes.constData(); 316 316 enum { OptType_Unknown, OptType_VMRunner, OptType_VMSelector, OptType_MaybeBoth } enmOptType = OptType_Unknown; 317 318 const char *pszSep = NULL; 319 #define MATCH_OPT_WITH_VALUE(a_szOption) \ 320 ( !::strncmp(arg,RT_STR_TUPLE(a_szOption)) \ 321 && ( *(pszSep = &arg[sizeof(a_szOption) - 1]) == '\0' \ 322 || *pszSep == '=' \ 323 || *pszSep == ':') ) 324 #define ASSIGN_OPT_VALUE_TO_QSTRING(a_strDst) do { \ 325 if (*pszSep != '\0') \ 326 (a_strDst) = &pszSep[1]; \ 327 else if (++i < argc) \ 328 (a_strDst) = arguments.at(i); \ 329 else \ 330 (a_strDst).clear(); \ 331 } while (0) 332 #define ASSIGN_OPT_VALUE_TO_QUUID(a_uuidDst) do { \ 333 if (*pszSep != '\0') \ 334 (a_uuidDst) = QUuid(&pszSep[1]); \ 335 else if (++i < argc) \ 336 (a_uuidDst) = QUuid(arguments.at(i)); \ 337 else \ 338 (a_uuidDst) = QUuid(); /* null UUID */ \ 339 } while (0) 340 317 341 /* NOTE: the check here must match the corresponding check for the 318 342 * options to start a VM in main.cpp and hardenedmain.cpp exactly, 319 343 * otherwise there will be weird error messages. */ 320 if ( !::strcmp(arg, "--startvm") 321 || !::strcmp(arg, "-startvm")) 322 { 323 enmOptType = OptType_VMRunner; 324 if (++i < argc) 325 { 326 vmNameOrUuid = arguments.at(i); 327 startVM = true; 328 } 344 if ( MATCH_OPT_WITH_VALUE("--startvm") 345 || MATCH_OPT_WITH_VALUE("-startvm") /* legacy */) 346 { 347 enmOptType = OptType_VMRunner; 348 ASSIGN_OPT_VALUE_TO_QSTRING(vmNameOrUuid); 349 startVM = true; 329 350 } 330 351 else if (!::strcmp(arg, "-separate") || !::strcmp(arg, "--separate")) … … 334 355 } 335 356 #ifdef VBOX_GUI_WITH_PIDFILE 336 else if ( !::strcmp(arg, "-pidfile") || !::strcmp(arg, "--pidfile"))357 else if (MATCH_OPT_WITH_VALUE("--pidfile") || MATCH_OPT_WITH_VALUE("-pidfile")) 337 358 { 338 359 enmOptType = OptType_MaybeBoth; 339 if (++i < argc) 340 m_strPidFile = arguments.at(i); 360 ASSIGN_OPT_VALUE_TO_QSTRING(m_strPidFile); 341 361 } 342 362 #endif /* VBOX_GUI_WITH_PIDFILE */ … … 363 383 } 364 384 /* Passwords: */ 365 else if ( !::strcmp(arg, "--settingspw"))385 else if (MATCH_OPT_WITH_VALUE("--settingspw") || MATCH_OPT_WITH_VALUE("--settings-pw")) 366 386 { 367 387 enmOptType = OptType_MaybeBoth; 368 if (++i < argc) 388 if (*pszSep == '\0') 389 RTStrCopy(m_astrSettingsPw, sizeof(m_astrSettingsPw), &pszSep[1]); 390 else if (++i < argc) 391 RTStrCopy(m_astrSettingsPw, sizeof(m_astrSettingsPw), arguments.at(i).toLocal8Bit().constData()); 392 else 393 m_astrSettingsPw[0] = '\0'; 394 m_fSettingsPwSet = m_astrSettingsPw[0] != '\0'; 395 } 396 else if (MATCH_OPT_WITH_VALUE("--settingspwfile") || MATCH_OPT_WITH_VALUE("--settings-pw-file")) 397 { 398 enmOptType = OptType_MaybeBoth; 399 QString strFilename; 400 ASSIGN_OPT_VALUE_TO_QSTRING(strFilename); 401 if (!strFilename.isEmpty()) 369 402 { 370 RTStrCopy(m_astrSettingsPw, sizeof(m_astrSettingsPw), arguments.at(i).toLocal8Bit().constData()); 371 m_fSettingsPwSet = true; 372 } 373 } 374 else if (!::strcmp(arg, "--settingspwfile")) 375 { 376 enmOptType = OptType_MaybeBoth; 377 if (++i < argc) 378 { 379 const QByteArray &argFileBytes = arguments.at(i).toLocal8Bit(); 403 const QByteArray &argFileBytes = strFilename.toLocal8Bit(); 380 404 const char *pszFile = argFileBytes.constData(); 381 405 bool fStdIn = !::strcmp(pszFile, "stdin"); … … 406 430 } 407 431 /* Misc options: */ 408 else if ( !::strcmp(arg, "-comment") || !::strcmp(arg,"--comment"))432 else if (MATCH_OPT_WITH_VALUE("--comment") || MATCH_OPT_WITH_VALUE("--comment")) 409 433 { 410 434 enmOptType = OptType_MaybeBoth; 411 ++i; 435 if (*pszSep == '\0') 436 ++i; /* we completely ignore the option value here, it's here only for 'ps' listing. */ 412 437 } 413 438 else if (!::strcmp(arg, "--no-startvm-errormsgbox")) … … 432 457 m_strSnapshotToRestore.clear(); 433 458 } 434 else if ( !::strcmp(arg, "--restore-snapshot") 435 || !::strncmp(arg, RT_STR_TUPLE("--restore-snapshot=")) 436 || !::strncmp(arg, RT_STR_TUPLE("--restore-snapshot:"))) 437 { 438 enmOptType = OptType_VMRunner; 439 const char * const pszSep = &arg[sizeof("--restore-snapshot") - 1]; 440 if (*pszSep != '\0') 441 m_strSnapshotToRestore = &pszSep[1]; 442 else if (++i < argc) 443 m_strSnapshotToRestore = arguments.at(i); 444 else 445 m_strSnapshotToRestore.clear(); 459 else if (MATCH_OPT_WITH_VALUE("--restore-snapshot")) 460 { 461 enmOptType = OptType_VMRunner; 462 ASSIGN_OPT_VALUE_TO_QSTRING(m_strSnapshotToRestore); 446 463 m_fRestoreCurrentSnapshot = false; 447 464 } … … 452 469 } 453 470 /* Ad hoc VM reconfig options: */ 454 else if ( !::strcmp(arg,"--fda"))455 { 456 enmOptType = OptType_VMRunner; 457 if (++i < argc) 458 m_uFloppyImage = QUuid(arguments.at(i));459 } 460 else if ( !::strcmp(arg, "--dvd") || !::strcmp(arg,"--cdrom"))461 { 462 enmOptType = OptType_VMRunner; 463 if (++i < argc) 464 m_uDvdImage = QUuid(arguments.at(i));471 else if (MATCH_OPT_WITH_VALUE("--fda")) 472 { 473 enmOptType = OptType_VMRunner; 474 /** @todo r=bird: this isn't correct. Must use QString instead of QUuid to store this! */ 475 ASSIGN_OPT_VALUE_TO_QUUID(m_uFloppyImage); 476 } 477 else if (MATCH_OPT_WITH_VALUE("--dvd") || MATCH_OPT_WITH_VALUE("--cdrom")) 478 { 479 enmOptType = OptType_VMRunner; 480 /** @todo r=bird: this isn't correct. Must use QString instead of QUuid to store this! */ 481 ASSIGN_OPT_VALUE_TO_QUUID(m_uDvdImage); 465 482 } 466 483 /* VMM Options: */ … … 472 489 else if (!::strcmp(arg, "--driverless")) 473 490 enmOptType = OptType_VMRunner; 474 else if (!::strcmp(arg, "--warp-pct")) 475 { 476 enmOptType = OptType_VMRunner; 477 if (++i < argc) 478 m_uWarpPct = RTStrToUInt32(arguments.at(i).toLocal8Bit().constData()); 491 else if (MATCH_OPT_WITH_VALUE("--warp-pct")) 492 { 493 enmOptType = OptType_VMRunner; 494 QString strValue; 495 ASSIGN_OPT_VALUE_TO_QSTRING(strValue); 496 m_uWarpPct = strValue.isEmpty() ? 100 : RTStrToUInt32(strValue.toLocal8Bit().constData()); 479 497 } 480 498 #ifdef VBOX_WITH_DEBUGGER_GUI … … 507 525 setDebuggerVar(&m_fDbgAutoShowStatistics, true); 508 526 } 509 else if (!::strcmp(arg, "--statistics-expand") || !::strcmp(arg, "--stats-expand")) 510 { 511 enmOptType = OptType_VMRunner; 512 if (++i < argc) 527 else if (MATCH_OPT_WITH_VALUE("--statistics-expand") || MATCH_OPT_WITH_VALUE("--stats-expand")) 528 { 529 enmOptType = OptType_VMRunner; 530 QString strValue; 531 ASSIGN_OPT_VALUE_TO_QSTRING(strValue); 532 if (!strValue.isEmpty()) 513 533 { 514 534 if (!m_strDbgStatisticsExpand.isEmpty()) 515 535 m_strDbgStatisticsExpand.append('|'); 516 m_strDbgStatisticsExpand.append( arguments.at(i));536 m_strDbgStatisticsExpand.append(strValue); 517 537 } 518 538 } 519 else if (!::strncmp(arg, RT_STR_TUPLE("--statistics-expand=")) || !::strncmp(arg, RT_STR_TUPLE("--stats-expand="))) 520 { 521 enmOptType = OptType_VMRunner; 522 if (!m_strDbgStatisticsExpand.isEmpty()) 523 m_strDbgStatisticsExpand.append('|'); 524 m_strDbgStatisticsExpand.append(arguments.at(i).section('=', 1)); 525 } 526 else if (!::strcmp(arg, "--statistics-filter") || !::strcmp(arg, "--stats-filter")) 527 { 528 enmOptType = OptType_VMRunner; 529 if (++i < argc) 530 m_strDbgStatisticsFilter = arguments.at(i); 531 } 532 else if (!::strncmp(arg, RT_STR_TUPLE("--statistics-filter=")) || !::strncmp(arg, RT_STR_TUPLE("--stats-filter="))) 533 { 534 enmOptType = OptType_VMRunner; 535 m_strDbgStatisticsFilter = arguments.at(i).section('=', 1); 536 } 537 else if (!::strcmp(arg, "--statistics-config") || !::strcmp(arg, "--stats-config")) 538 { 539 enmOptType = OptType_VMRunner; 540 if (++i < argc) 541 m_strDbgStatisticsConfig = arguments.at(i); 542 } 543 else if (!::strncmp(arg, RT_STR_TUPLE("--statistics-config=")) || !::strncmp(arg, RT_STR_TUPLE("--stats-config="))) 544 { 545 enmOptType = OptType_VMRunner; 546 m_strDbgStatisticsConfig = arguments.at(i).section('=', 1); 539 else if (MATCH_OPT_WITH_VALUE("--statistics-filter") || MATCH_OPT_WITH_VALUE("--stats-filter")) 540 { 541 enmOptType = OptType_VMRunner; 542 ASSIGN_OPT_VALUE_TO_QSTRING(m_strDbgStatisticsFilter); 543 } 544 else if (MATCH_OPT_WITH_VALUE("--statistics-config") || MATCH_OPT_WITH_VALUE("--stats-config")) 545 { 546 enmOptType = OptType_VMRunner; 547 ASSIGN_OPT_VALUE_TO_QSTRING(m_strDbgStatisticsConfig); 547 548 } 548 549 else if (!::strcmp(arg, "-no-debug") || !::strcmp(arg, "--no-debug")) … … 571 572 i++; 572 573 } 574 #undef MATCH_OPT_WITH_VALUE 575 #undef ASSIGN_OPT_VALUE_TO_QSTRING 576 #undef ASSIGN_OPT_VALUE_TO_QUUID 573 577 574 578 if (uiType() == UIType_RuntimeUI && startVM) -
trunk/src/VBox/Frontends/VirtualBox/src/main.cpp
r105546 r105547 273 273 #ifdef VBOX_RUNTIME_UI 274 274 "Options:\n" 275 " --startvm 275 " --startvm=<vmname|UUID> start a VM by specifying its UUID or name\n" 276 276 " --separate start a separate VM process\n" 277 277 " --normal keep normal (windowed) mode during startup\n" … … 283 283 " --restore-snapshot=<name> restore the named snapshot before starting\n" 284 284 " --no-aggressive-caching delays caching media info in VM processes\n" 285 " --fda 286 " --dvd 285 " --fda=<image|none> Mount the specified floppy image\n" 286 " --dvd=<image|none> Mount the specified DVD image\n" 287 287 # ifdef VBOX_GUI_WITH_PIDFILE 288 " --pidfile 288 " --pidfile=<file> create a pidfile file when a VM is up and running\n" 289 289 # endif /* VBOX_GUI_WITH_PIDFILE */ 290 290 # ifdef VBOX_WITH_DEBUGGER_GUI … … 293 293 " --debug-command-line like --dbg and show command line window at VM startup\n" 294 294 " --debug-statistics like --dbg and show statistics window at VM startup\n" 295 " --statistics-expand 296 " --statistics-filter 297 " --statistics-config 295 " --statistics-expand=<pat> expand the matching statistics (can be repeated)\n" 296 " --statistics-filter=<pat> statistics filter\n" 297 " --statistics-config=<str> statistics configuration\n" 298 298 " --no-debug disable the GUI debug menu and debug windows\n" 299 299 " --start-paused start the VM in the paused state\n" … … 304 304 " --execute-all-in-iem For debugging the interpreted execution mode.\n" 305 305 " --driverless Do not open the support driver (NEM or IEM mode).\n" 306 " --warp-pct 306 " --warp-pct=<pct> time warp factor, 100%% (= 1.0) = normal speed\n" 307 307 " --no-keyboard-grabbing Don't grab the keyboard on windows (for debugging).\n" 308 308 "\n"
Note:
See TracChangeset
for help on using the changeset viewer.