Changeset 7379 in vbox
- Timestamp:
- Mar 7, 2008 10:47:01 PM (17 years ago)
- Location:
- trunk/src/VBox/Frontends
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VBoxManage/VBoxManage.cpp
r7207 r7379 27 27 #include <VBox/com/string.h> 28 28 #include <VBox/com/Guid.h> 29 #include <VBox/com/array.h> 29 30 #include <VBox/com/ErrorInfo.h> 30 31 #include <VBox/com/EventQueue.h> … … 32 33 #include <VBox/com/VirtualBox.h> 33 34 34 /// @todo later, when the settings file update funciton is reimplemented using35 /// libxslt (search for CFGLDR to find related parts of code below)36 // #include <VBox/settings.h>37 38 35 #include <stdlib.h> 39 36 #include <stdarg.h> 40 37 41 38 #include <vector> 39 #include <list> 42 40 43 41 #include <iprt/runtime.h> … … 261 259 if (u64Cmd == USAGE_ALL) 262 260 { 263 RTPrintf("VBoxManage [-v|-version] print version number and exit\n"); 264 RTPrintf("VBoxManage -nologo ... suppress the logo\n" 261 RTPrintf("VBoxManage [-v|-version] print version number and exit\n" 262 "VBoxManage -nologo ... suppress the logo\n" 263 "\n" 264 "VBoxManage -convertSettings ... allow to auto-convert settings files\n" 265 "VBoxManage -convertSettingsBackup ... allow to auto-convert settings files\n" 266 " but create backup copies before\n" 267 "VBoxManage -convertSettingsIgnore ... allow to auto-convert settings files\n" 268 " but don't explicitly save the results\n" 265 269 "\n"); 266 270 } … … 608 612 RTPrintf("VBoxManage sharedfolder remove <vmname>|<uuid>\n" 609 613 " -name <name> [-transient]\n" 610 "\n");611 }612 613 if (u64Cmd & USAGE_UPDATESETTINGS)614 {615 RTPrintf("VBoxManage updatesettings [<dir>|<file>] [-apply]\n"616 " [-nobackup] [-skipinvalid]\n"617 614 "\n"); 618 615 } … … 7387 7384 } 7388 7385 7389 enum HUSPD { HUSPD_DryRun, HUSPD_Apply, HUSPD_ApplyNoBackup }; 7390 7391 static int handleUpdateSettings_processFile (const char *filePath, HUSPD mode) 7386 enum ConvertSettings 7392 7387 { 7393 RTPrintf ("%s\n", filePath); 7394 7395 /// @todo later, when the settings file update funciton is reimplemented using 7396 /// libxslt (search for CFGLDR to find related parts of code below). Note that 7397 /// it doesn't make sense to enable this code since CFGLDR is no more 7398 /// available. 7399 #if 0 7400 7401 CFGHANDLE config = 0; 7402 char *errMsg = NULL; 7403 7404 int vrc = CFGLDRLoad (&config, filePath, NIL_RTFILE, 7405 NULL, false, NULL, //cfgLdrEntityResolver, 7406 &errMsg); 7407 if (VBOX_SUCCESS (vrc)) 7408 { 7409 CFGNODE vbox = 0; 7410 CFGLDRGetNode (config, "VirtualBox", 0, &vbox); 7388 ConvertSettings_No = 0, 7389 ConvertSettings_Yes = 1, 7390 ConvertSettings_Backup = 2, 7391 ConvertSettings_Ignore = 3, 7392 }; 7393 7394 /** 7395 * Checks if any of the settings files were auto-converted and informs the 7396 * user if so. 7397 * 7398 * @return @false if the program should terminate and @true otherwise. 7399 */ 7400 static bool checkForAutoConvertedSettings (ComPtr<IVirtualBox> virtualBox, 7401 ComPtr<ISession> session, 7402 ConvertSettings fConvertSettings) 7403 { 7404 /* return early if nothing to do */ 7405 if (fConvertSettings == ConvertSettings_Ignore) 7406 return true; 7407 7408 HRESULT rc; 7409 7410 do 7411 { 7412 Bstr formatVersion; 7413 CHECK_RC_BREAK (virtualBox-> 7414 COMGETTER(SettingsFormatVersion) (formatVersion.asOutParam())); 7415 7416 bool isGlobalConverted = false; 7417 std::list <ComPtr <IMachine> > cvtMachines; 7418 std::list <Utf8Str> fileList; 7411 7419 Bstr version; 7412 CFGLDRQueryBSTR (vbox, "version", version.asOutParam()); 7413 CFGLDRReleaseNode (vbox); 7414 7415 RTPrintf (" current version : %ls\n", version.raw()); 7416 7417 /// @todo (dmik) use cfgLdrEntityResolver later 7418 vrc = CFGLDRTransform (config, "SettingsConverter.xsl", NULL, &errMsg); 7419 if (VBOX_SUCCESS (vrc)) 7420 { 7421 CFGLDRGetNode (config, "VirtualBox", 0, &vbox); 7422 CFGLDRQueryBSTR (vbox, "version", version.asOutParam()); 7423 CFGLDRReleaseNode (vbox); 7424 7425 RTPrintf (" new version : %ls\n\n", version.raw()); 7426 7427 if (mode != HUSPD_DryRun) 7428 { 7429 if (mode != HUSPD_ApplyNoBackup) 7430 { 7431 Utf8StrFmt filePathBak ("%s.bak", filePath); 7432 vrc = RTFileCopy (filePath, filePathBak); 7433 if (VBOX_FAILURE (vrc)) 7434 { 7435 RTPrintf ("Error copying '%s' to '%s' (%Vrc)\n", 7436 filePath, filePathBak.raw(), vrc); 7437 } 7438 } 7439 7440 if (VBOX_SUCCESS (vrc)) 7441 { 7442 vrc = CFGLDRSave (config, &errMsg); 7443 if (VBOX_FAILURE (vrc)) 7444 { 7445 RTPrintf ("Error saving the settings file '%s' (%Vrc)%s%s\n", 7446 filePath, vrc, 7447 errMsg ? "\n" : "", errMsg ? errMsg : ""); 7448 } 7449 } 7450 } 7451 } 7452 else 7453 { 7454 RTPrintf ("Could not convert the settings file '%s' (%Vrc)%s%s\n", 7455 filePath, vrc, errMsg ? "\n" : "", errMsg ? errMsg : ""); 7456 } 7457 7458 CFGLDRFree (config); 7459 } 7460 else 7461 { 7462 RTPrintf ("Error loading the settings file '%s' (%Vrc)%s%s\n", 7463 filePath, vrc, errMsg ? "\n" : "", errMsg ? errMsg : ""); 7464 } 7465 7466 if (errMsg) 7467 RTStrFree (errMsg); 7468 7469 return vrc; 7470 7471 #else 7472 7473 RTPrintf ("Error converting settings file '%s': " 7474 "THE FUNCTION IS TEMPORARILY DISABLED!\n"); 7475 return 1; 7476 7477 #endif 7478 } 7479 7480 static int handleUpdateSettings_processDir (const char *dirPath, HUSPD mode, 7481 bool skipInvalid) 7482 { 7483 PRTDIR dir; 7484 int vrc = RTDirOpen (&dir, dirPath); 7485 if (VBOX_FAILURE (vrc)) 7486 { 7487 return vrc; 7488 } 7489 7490 RTDIRENTRYEX entry; 7491 while (VBOX_SUCCESS (vrc)) 7492 { 7493 vrc = RTDirReadEx (dir, &entry, NULL, RTFSOBJATTRADD_UNIX); 7494 if (VBOX_FAILURE (vrc)) 7495 { 7496 if (vrc == VERR_NO_MORE_FILES) 7497 vrc = VINF_SUCCESS; 7498 else 7499 RTPrintf ("Error reading directory '%s' (%Vrc)\n", dirPath, vrc); 7500 break; 7501 } 7502 7503 if (RTFS_IS_DIRECTORY (entry.Info.Attr.fMode)) 7504 { 7505 if (entry.szName[0] == '.' && 7506 (entry.szName[1] == 0 || 7507 (entry.szName[1] == '.' && entry.szName[2] == 0))) 7420 Bstr filePath; 7421 7422 com::SafeIfaceArray <IMachine> machines; 7423 CHECK_RC_BREAK (virtualBox-> 7424 COMGETTER(Machines2) (ComSafeArrayAsOutParam (machines))); 7425 7426 for (size_t i = 0; i < machines.size(); ++ i) 7427 { 7428 BOOL accessible; 7429 CHECK_RC_BREAK (machines [i]-> 7430 COMGETTER(Accessible) (&accessible)); 7431 if (!accessible) 7508 7432 continue; 7509 7433 7510 vrc = handleUpdateSettings_processDir ( 7511 Utf8StrFmt ("%s%c%s", dirPath, RTPATH_DELIMITER, entry.szName), 7512 mode, skipInvalid); 7513 if (VBOX_FAILURE (vrc)) 7514 break; 7515 7516 continue; 7517 } 7518 else if (RTFS_IS_FILE (entry.Info.Attr.fMode)) 7519 { 7520 const char *ext = RTPathExt (entry.szName); 7521 if (!ext || strcmp (ext, ".xml") != 0) 7522 continue; 7523 } 7524 else 7525 continue; 7526 7527 Utf8Str filePath = Utf8StrFmt ("%s%c%s", dirPath, RTPATH_DELIMITER, 7528 entry.szName); 7529 7530 vrc = handleUpdateSettings_processFile (filePath, mode); 7531 7532 if (skipInvalid) 7533 vrc = VINF_SUCCESS; 7534 } 7535 7536 RTDirClose (dir); 7537 7538 return vrc; 7539 } 7540 7541 static int handleUpdateSettings (int argc, char *argv[]) 7542 { 7543 const char *dirOrFilePath = NULL; 7544 bool apply = false; 7545 bool nobackup = false; 7546 bool skipinvalid = false; 7547 7548 for (int i = 0; i < argc; i++) 7549 { 7550 if (i == 0 && argv[i][0] != '-') 7551 { 7552 dirOrFilePath = argv[i]; 7553 } 7554 else if (argv[i][0] == '-') 7555 { 7556 if (strcmp (&argv[i][1], "apply") == 0) 7557 apply = true; 7558 else if (strcmp (&argv[i][1], "nobackup") == 0) 7559 nobackup = true; 7560 else if (strcmp (&argv[i][1], "skipinvalid") == 0) 7561 skipinvalid = true; 7562 else 7563 { 7564 return errorSyntax(USAGE_UPDATESETTINGS, "Invalid parameter '%s'", Utf8Str(argv[i]).raw()); 7565 } 7566 } 7567 else 7568 { 7569 return errorSyntax(USAGE_UPDATESETTINGS, "Invalid parameter '%s'", Utf8Str(argv[i]).raw()); 7570 } 7571 } 7572 7573 HUSPD mode = HUSPD_DryRun; 7574 if (apply) 7575 mode = nobackup ? HUSPD_ApplyNoBackup : HUSPD_Apply; 7576 7577 /// @todo later, when the settings file update funciton is reimplemented using 7578 /// libxslt (search for CFGLDR to find related parts of code below). Note that 7579 /// it doesn't make sense to enable this code since CFGLDR is no more 7580 /// available. 7581 #if 0 7582 7583 int vrc = CFGLDRInitialize(); 7584 if (VBOX_FAILURE (vrc)) 7585 { 7586 RTPrintf ("Could not initialize XML subsystem (%Vrc)\n", vrc); 7587 return 1; 7588 } 7589 7590 if (dirOrFilePath) 7591 { 7592 if (RTDirExists (dirOrFilePath)) 7593 { 7594 char fullPath [RTPATH_MAX]; 7595 vrc = RTPathReal (dirOrFilePath, fullPath, RTPATH_MAX); 7596 if (VBOX_FAILURE (vrc)) 7597 { 7598 RTPrintf ("Invalid directory path '%s' (%Vrc)\n", dirOrFilePath, vrc); 7599 return 1; 7600 } 7601 7602 RTPrintf ("Updating settings files in the following directory:\n" 7603 "\n %s\n\n", fullPath); 7604 7605 vrc = handleUpdateSettings_processDir (dirOrFilePath, mode, skipinvalid); 7606 } 7607 else 7608 { 7609 vrc = handleUpdateSettings_processFile (dirOrFilePath, mode); 7610 } 7611 } 7612 else 7613 { 7614 char homeDir [RTPATH_MAX]; 7615 vrc = GetVBoxUserHomeDirectory (homeDir, sizeof (homeDir)); 7616 7617 AssertRC (vrc); 7618 if (VBOX_SUCCESS (vrc)) 7619 { 7620 RTPrintf ("Updating settings files in the following VirtualBox Home Directory:\n" 7621 "\n %s\n\n", homeDir); 7622 7623 vrc = handleUpdateSettings_processDir (homeDir, mode, skipinvalid); 7624 } 7625 } 7626 7627 if (mode == HUSPD_DryRun) 7628 { 7629 RTPrintf ("NOTE: No actual changes to the setting files were made.\n" 7630 " Repeat the command with the -apply option supplied.\n"); 7631 } 7632 7633 CFGLDRShutdown(); 7634 7635 return VBOX_SUCCESS (vrc) ? 0 : 1; 7636 7637 #else 7638 7639 NOREF (mode); 7640 7641 RTPrintf ("THE SETTINGS FILE UPDATE FUNCTION IS TEMPORARILY DISABLED!\n"); 7642 return 1; 7643 7644 7645 #endif 7434 CHECK_RC_BREAK (machines [i]-> 7435 COMGETTER(SettingsFileVersion) (version.asOutParam())); 7436 7437 if (version != formatVersion) 7438 { 7439 cvtMachines.push_back (machines [i]); 7440 Bstr filePath; 7441 CHECK_RC_BREAK (machines [i]-> 7442 COMGETTER(SettingsFilePath) (filePath.asOutParam())); 7443 fileList.push_back (Utf8StrFmt ("%ls (%ls)", filePath.raw(), 7444 version.raw())); 7445 } 7446 } 7447 7448 CHECK_RC_BREAK (rc); 7449 7450 CHECK_RC_BREAK (virtualBox-> 7451 COMGETTER(SettingsFileVersion) (version.asOutParam())); 7452 if (version != formatVersion) 7453 { 7454 isGlobalConverted = true; 7455 CHECK_RC_BREAK (virtualBox-> 7456 COMGETTER(SettingsFilePath) (filePath.asOutParam())); 7457 fileList.push_back (Utf8StrFmt ("%ls (%ls)", filePath.raw(), 7458 version.raw())); 7459 } 7460 7461 if (fileList.size() > 0) 7462 { 7463 switch (fConvertSettings) 7464 { 7465 case ConvertSettings_No: 7466 { 7467 RTPrintf ( 7468 "WARNING! The following VirtualBox settings files have been automatically\n" 7469 "converted to the new settings file format version '%ls':\n" 7470 "\n", 7471 formatVersion.raw()); 7472 7473 for (std::list <Utf8Str>::const_iterator f = fileList.begin(); 7474 f != fileList.end(); ++ f) 7475 RTPrintf (" %S\n", (*f).raw()); 7476 RTPrintf ( 7477 "\n" 7478 "The current command was aborted to prevent overwriting the above settings\n" 7479 "files with the results of the auto-conversion without your permission.\n" 7480 "Please put one of the following command line switches to the beginning of\n" 7481 "the VBoxManage command line and repeat the command:\n" 7482 "\n" 7483 " -convertSettings - to save all auto-converted files (it will not\n" 7484 " be possible to use these settings files with an\n" 7485 " older version of VirtualBox in the future);\n" 7486 " -convertSettingsBackup - to create backup copies of the settings files in\n" 7487 " the old format before saving them in the new format;\n" 7488 " -convertSettingsIgnore - to not save the auto-converted settings files.\n" 7489 "\n" 7490 "Note that if you use -convertSettingsIgnore, the auto-converted settings files\n" 7491 "will be implicitly saved in the new format anyway once you change a setting or\n" 7492 "start a virtual machine, but NO backup copies will be created in this case.\n"); 7493 return false; 7494 } 7495 case ConvertSettings_Yes: 7496 case ConvertSettings_Backup: 7497 { 7498 break; 7499 } 7500 default: 7501 AssertFailedReturn (false); 7502 } 7503 7504 for (std::list <ComPtr <IMachine> >::const_iterator m = cvtMachines.begin(); 7505 m != cvtMachines.end(); ++ m) 7506 { 7507 Guid id; 7508 CHECK_RC_BREAK ((*m)->COMGETTER(Id) (id.asOutParam())); 7509 7510 /* open a session for the VM */ 7511 CHECK_ERROR_BREAK (virtualBox, OpenSession (session, id)); 7512 7513 ComPtr <IMachine> sm; 7514 CHECK_RC_BREAK (session->COMGETTER(Machine) (sm.asOutParam())); 7515 7516 Bstr bakFileName; 7517 if (fConvertSettings == ConvertSettings_Backup) 7518 CHECK_ERROR (sm, SaveSettingsWithBackup (bakFileName.asOutParam())); 7519 else 7520 CHECK_ERROR (sm, SaveSettings()); 7521 7522 session->Close(); 7523 7524 CHECK_RC_BREAK (rc); 7525 } 7526 7527 CHECK_RC_BREAK (rc); 7528 7529 if (isGlobalConverted) 7530 { 7531 Bstr bakFileName; 7532 if (fConvertSettings == ConvertSettings_Backup) 7533 CHECK_ERROR (virtualBox, SaveSettingsWithBackup (bakFileName.asOutParam())); 7534 else 7535 CHECK_ERROR (virtualBox, SaveSettings()); 7536 } 7537 7538 CHECK_RC_BREAK (rc); 7539 } 7540 } 7541 while (0); 7542 7543 return SUCCEEDED (rc); 7646 7544 } 7647 7545 … … 7661 7559 int iCmdArg; 7662 7560 7561 ConvertSettings fConvertSettings = ConvertSettings_No; 7562 7563 /* global options */ 7663 7564 for (int i = 1; i < argc || argc <= iCmd; i++) 7664 7565 { … … 7683 7584 exit(0); 7684 7585 } 7685 else if (strcmp(argv[i], "-nologo") == 0)7686 {7687 /* suppress the logo */7688 fShowLogo = false;7689 iCmd++;7690 }7691 7586 else if (strcmp(argv[i], "-dumpopts") == 0) 7692 7587 { … … 7695 7590 printUsage(USAGE_DUMPOPTS); 7696 7591 return 0; 7592 } 7593 else if (strcmp(argv[i], "-nologo") == 0) 7594 { 7595 /* suppress the logo */ 7596 fShowLogo = false; 7597 iCmd++; 7598 } 7599 else if (strcmp(argv[i], "-convertSettings") == 0) 7600 { 7601 fConvertSettings = ConvertSettings_Yes; 7602 iCmd++; 7603 } 7604 else if (strcmp(argv[i], "-convertSettingsBackup") == 0) 7605 { 7606 fConvertSettings = ConvertSettings_Backup; 7607 iCmd++; 7608 } 7609 else if (strcmp(argv[i], "-convertSettingsIgnore") == 0) 7610 { 7611 fConvertSettings = ConvertSettings_Ignore; 7612 iCmd++; 7697 7613 } 7698 7614 else … … 7727 7643 // scopes all the stuff till shutdown 7728 7644 //////////////////////////////////////////////////////////////////////////// 7729 7730 /* update settings command (no VirtualBox instantiation!) */7731 if (argc >= iCmdArg && (strcmp(argv[iCmd], "updatesettings") == 0))7732 {7733 rc = handleUpdateSettings(argc - iCmdArg, argv + iCmdArg);7734 break;7735 }7736 7645 7737 7646 /* convertdd: does not need a VirtualBox instantiation) */ … … 7767 7676 7768 7677 EventQueue eventQ; 7678 7679 if (!checkForAutoConvertedSettings (virtualBox, session, fConvertSettings)) 7680 break; 7769 7681 7770 7682 /* -
trunk/src/VBox/Frontends/VBoxManage/VBoxManage.h
r5999 r7379 55 55 #define USAGE_SHAREDFOLDER_ADD RT_BIT_64(25) 56 56 #define USAGE_SHAREDFOLDER_REMOVE RT_BIT_64(26) 57 #define USAGE_UPDATESETTINGS RT_BIT_64(27)58 57 #define USAGE_LOADSYMS RT_BIT_64(29) 59 58 #define USAGE_UNLOADSYMS RT_BIT_64(30) -
trunk/src/VBox/Frontends/VBoxSDL/VBoxSDL.cpp
r7207 r7379 24 24 #include <VBox/com/string.h> 25 25 #include <VBox/com/Guid.h> 26 #include <VBox/com/array.h> 26 27 #include <VBox/com/ErrorInfo.h> 27 28 #include <VBox/com/EventQueue.h> … … 64 65 65 66 #include <vector> 67 #include <list> 66 68 67 69 /* Xlib would re-define our enums */ … … 668 670 #endif 669 671 "\n" 672 " -convertSettings Allow to auto-convert settings files\n" 673 " -convertSettingsBackup Allow to auto-convert settings files\n" 674 " but create backup copies before\n" 675 " -convertSettingsIgnore Allow to auto-convert settings files\n" 676 " but don't explicitly save the results\n" 677 "\n" 670 678 "Key bindings:\n" 671 679 " <hostkey> + f Switch to full screen / restore to previous view\n" … … 725 733 } 726 734 #endif /* VBOXSDL_WITH_X11 */ 735 736 enum ConvertSettings 737 { 738 ConvertSettings_No = 0, 739 ConvertSettings_Yes = 1, 740 ConvertSettings_Backup = 2, 741 ConvertSettings_Ignore = 3, 742 }; 743 744 /** 745 * Checks if any of the settings files were auto-converted and informs the 746 * user if so. 747 * 748 * @return @false if the program should terminate and @true otherwise. 749 * 750 * @note The function is taken from VBoxManage.cpp almost unchanged (except the 751 * help text). 752 */ 753 static bool checkForAutoConvertedSettings (ComPtr<IVirtualBox> virtualBox, 754 ComPtr<ISession> session, 755 ConvertSettings fConvertSettings) 756 { 757 /* return early if nothing to do */ 758 if (fConvertSettings == ConvertSettings_Ignore) 759 return true; 760 761 HRESULT rc; 762 763 do 764 { 765 Bstr formatVersion; 766 CHECK_RC_BREAK (virtualBox-> 767 COMGETTER(SettingsFormatVersion) (formatVersion.asOutParam())); 768 769 bool isGlobalConverted = false; 770 std::list <ComPtr <IMachine> > cvtMachines; 771 std::list <Utf8Str> fileList; 772 Bstr version; 773 Bstr filePath; 774 775 com::SafeIfaceArray <IMachine> machines; 776 CHECK_RC_BREAK (virtualBox-> 777 COMGETTER(Machines2) (ComSafeArrayAsOutParam (machines))); 778 779 for (size_t i = 0; i < machines.size(); ++ i) 780 { 781 BOOL accessible; 782 CHECK_RC_BREAK (machines [i]-> 783 COMGETTER(Accessible) (&accessible)); 784 if (!accessible) 785 continue; 786 787 CHECK_RC_BREAK (machines [i]-> 788 COMGETTER(SettingsFileVersion) (version.asOutParam())); 789 790 if (version != formatVersion) 791 { 792 cvtMachines.push_back (machines [i]); 793 Bstr filePath; 794 CHECK_RC_BREAK (machines [i]-> 795 COMGETTER(SettingsFilePath) (filePath.asOutParam())); 796 fileList.push_back (Utf8StrFmt ("%ls (%ls)", filePath.raw(), 797 version.raw())); 798 } 799 } 800 801 CHECK_RC_BREAK (rc); 802 803 CHECK_RC_BREAK (virtualBox-> 804 COMGETTER(SettingsFileVersion) (version.asOutParam())); 805 if (version != formatVersion) 806 { 807 isGlobalConverted = true; 808 CHECK_RC_BREAK (virtualBox-> 809 COMGETTER(SettingsFilePath) (filePath.asOutParam())); 810 fileList.push_back (Utf8StrFmt ("%ls (%ls)", filePath.raw(), 811 version.raw())); 812 } 813 814 if (fileList.size() > 0) 815 { 816 switch (fConvertSettings) 817 { 818 case ConvertSettings_No: 819 { 820 RTPrintf ( 821 "WARNING! The following VirtualBox settings files have been automatically\n" 822 "converted to the new settings file format version '%ls':\n" 823 "\n", 824 formatVersion.raw()); 825 826 for (std::list <Utf8Str>::const_iterator f = fileList.begin(); 827 f != fileList.end(); ++ f) 828 RTPrintf (" %S\n", (*f).raw()); 829 RTPrintf ( 830 "\n" 831 "The current command was aborted to prevent overwriting the above settings\n" 832 "files with the results of the auto-conversion without your permission.\n" 833 "Please add one of the following command line switches to the VBoxSDL command\n" 834 "line and repeat the command:\n" 835 "\n" 836 " -convertSettings - to save all auto-converted files (it will not\n" 837 " be possible to use these settings files with an\n" 838 " older version of VirtualBox in the future);\n" 839 " -convertSettingsBackup - to create backup copies of the settings files in\n" 840 " the old format before saving them in the new format;\n" 841 " -convertSettingsIgnore - to not save the auto-converted settings files.\n" 842 "\n" 843 "Note that if you use -convertSettingsIgnore, the auto-converted settings files\n" 844 "will be implicitly saved in the new format anyway once you change a setting or\n" 845 "start a virtual machine, but NO backup copies will be created in this case.\n"); 846 return false; 847 } 848 case ConvertSettings_Yes: 849 case ConvertSettings_Backup: 850 { 851 break; 852 } 853 default: 854 AssertFailedReturn (false); 855 } 856 857 for (std::list <ComPtr <IMachine> >::const_iterator m = cvtMachines.begin(); 858 m != cvtMachines.end(); ++ m) 859 { 860 Guid id; 861 CHECK_RC_BREAK ((*m)->COMGETTER(Id) (id.asOutParam())); 862 863 /* open a session for the VM */ 864 CHECK_ERROR_BREAK (virtualBox, OpenSession (session, id)); 865 866 ComPtr <IMachine> sm; 867 CHECK_RC_BREAK (session->COMGETTER(Machine) (sm.asOutParam())); 868 869 Bstr bakFileName; 870 if (fConvertSettings == ConvertSettings_Backup) 871 CHECK_ERROR (sm, SaveSettingsWithBackup (bakFileName.asOutParam())); 872 else 873 CHECK_ERROR (sm, SaveSettings()); 874 875 session->Close(); 876 877 CHECK_RC_BREAK (rc); 878 } 879 880 CHECK_RC_BREAK (rc); 881 882 if (isGlobalConverted) 883 { 884 Bstr bakFileName; 885 if (fConvertSettings == ConvertSettings_Backup) 886 CHECK_ERROR (virtualBox, SaveSettingsWithBackup (bakFileName.asOutParam())); 887 else 888 CHECK_ERROR (virtualBox, SaveSettings()); 889 } 890 891 CHECK_RC_BREAK (rc); 892 } 893 } 894 while (0); 895 896 return SUCCEEDED (rc); 897 } 727 898 728 899 /** entry point */ … … 987 1158 #endif 988 1159 1160 ConvertSettings fConvertSettings = ConvertSettings_No; 1161 989 1162 // command line argument parsing stuff 990 1163 for (int curArg = 1; curArg < argc; curArg++) … … 1327 1500 gHostKeyMod = atoi(argv[curArg]); 1328 1501 } 1502 else if (strcmp(argv[curArg], "-convertSettings") == 0) 1503 fConvertSettings = ConvertSettings_Yes; 1504 else if (strcmp(argv[curArg], "-convertSettingsBackup") == 0) 1505 fConvertSettings = ConvertSettings_Backup; 1506 else if (strcmp(argv[curArg], "-convertSettingsIgnore") == 0) 1507 fConvertSettings = ConvertSettings_Ignore; 1329 1508 /* just show the help screen */ 1330 1509 else … … 1339 1518 } 1340 1519 if (FAILED (rc)) 1520 break; 1521 1522 if (!checkForAutoConvertedSettings (virtualBox, session, fConvertSettings)) 1341 1523 break; 1342 1524
Note:
See TracChangeset
for help on using the changeset viewer.