Changeset 97367 in vbox
- Timestamp:
- Nov 1, 2022 10:38:05 AM (2 years ago)
- svn:sync-xref-src-repo-rev:
- 154365
- Location:
- trunk
- Files:
-
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/doc/manual/en_US/man_VBoxManage-unregistervm.xml
r97360 r97367 55 55 </group> 56 56 <arg>--delete</arg> 57 <arg>--delete-all</arg>58 57 </cmdsynopsis> 59 58 </refsynopsisdiv> … … 96 95 </itemizedlist></listitem> 97 96 </varlistentry> 98 <varlistentry>99 <term><option>--delete-all</option></term>100 <listitem><para>101 Deletes the files described in the <option>--delete</option> option,102 as well as all DVDs and Floppy disks located in the VM folder and103 attached only to this VM.104 </para></listitem>105 </varlistentry>106 97 </variablelist> 107 98 </refsect1> -
trunk/src/VBox/Frontends/VBoxManage/VBoxManageMisc.cpp
r97360 r97367 171 171 { "--delete", 'd', RTGETOPT_REQ_NOTHING }, 172 172 { "-delete", 'd', RTGETOPT_REQ_NOTHING }, // deprecated 173 { "--delete-all", 'a', RTGETOPT_REQ_NOTHING },174 { "-delete-all", 'a', RTGETOPT_REQ_NOTHING }, // deprecated175 173 }; 176 174 … … 180 178 const char *VMName = NULL; 181 179 bool fDelete = false; 182 bool fDeleteAll = false;183 180 184 181 int c; … … 194 191 case 'd': // --delete 195 192 fDelete = true; 196 break;197 198 case 'a': // --delete-all199 fDeleteAll = true;200 193 break; 201 194 … … 231 224 RTEXITCODE_FAILURE); 232 225 SafeIfaceArray<IMedium> aMedia; 233 CHECK_ERROR_RET(machine, Unregister(fDeleteAll ? CleanupMode_DetachAllReturnHardDisksAndVMRemovable 234 :CleanupMode_DetachAllReturnHardDisksOnly, 226 CHECK_ERROR_RET(machine, Unregister(CleanupMode_DetachAllReturnHardDisksOnly, 235 227 ComSafeArrayAsOutParam(aMedia)), 236 228 RTEXITCODE_FAILURE); 237 if (fDelete || fDeleteAll)229 if (fDelete) 238 230 { 239 231 ComPtr<IProgress> pProgress; -
trunk/src/VBox/Main/idl/VirtualBox.xidl
r97360 r97367 6517 6517 <enum 6518 6518 name="CleanupMode" 6519 uuid=" 1ec1df9e-9b0e-43cd-ad4d-a34e10edb0c5"6519 uuid="67897c50-7cca-47a9-83f6-ce8fd8eb5441" 6520 6520 > 6521 6521 <desc>Cleanup mode, used with <link to="IMachine::unregister" />. 6522 6522 </desc> 6523 <const name="UnregisterOnly" 6523 <const name="UnregisterOnly" value="1"> 6524 6524 <desc>Unregister only the machine, but neither delete snapshots nor detach media.</desc> 6525 6525 </const> 6526 <const name="DetachAllReturnNone" 6526 <const name="DetachAllReturnNone" value="2"> 6527 6527 <desc>Delete all snapshots and detach all media but return none; this will keep all media registered.</desc> 6528 6528 </const> 6529 <const name="DetachAllReturnHardDisksOnly" 6529 <const name="DetachAllReturnHardDisksOnly" value="3"> 6530 6530 <desc>Delete all snapshots, detach all media and return hard disks for closing, but not removable media.</desc> 6531 6531 </const> 6532 <const name="Full" 6532 <const name="Full" value="4"> 6533 6533 <desc>Delete all snapshots, detach all media and return all media for closing.</desc> 6534 </const>6535 <const name="DetachAllReturnHardDisksAndVMRemovable" value="5">6536 <desc>Delete all snapshots, detach all media and return hard disks and removable locating in the folder of the machine to be deleted and referenced only to this machine, for closing.</desc>6537 6534 </const> 6538 6535 </enum> -
trunk/src/VBox/Main/src-client/ConsoleImpl.cpp
r97359 r97367 68 68 #include "USBDeviceImpl.h" 69 69 #include "RemoteUSBDeviceImpl.h" 70 #include " ConsoleSharedFolderImpl.h"70 #include "SharedFolderImpl.h" 71 71 #ifdef VBOX_WITH_AUDIO_VRDE 72 72 # include "DrvAudioVRDE.h" -
trunk/src/VBox/Main/src-server/MachineImpl.cpp
r97359 r97367 49 49 #include "USBDeviceFiltersImpl.h" 50 50 #include "HostImpl.h" 51 #include " MachineSharedFolderImpl.h"51 #include "SharedFolderImpl.h" 52 52 #include "GuestOSTypeImpl.h" 53 53 #include "VirtualBoxErrorInfoImpl.h" … … 11896 11896 * adds hard disks to the list. If it is CleanupMode_Full, this adds all 11897 11897 * media to the list. 11898 * CleanupMode_DetachAllReturnHardDisksAndVMRemovable adds hard disk and11899 * also removable medias if they are located in the VM folder and referenced11900 * only by this VM (media prepared by unattended installer).11901 11898 * 11902 11899 * This gets called from Machine::Unregister, both for the actual Machine and … … 11944 11941 AutoReadLock lock(pMedium COMMA_LOCKVAL_SRC_POS); 11945 11942 DeviceType_T devType = pMedium->i_getDeviceType(); 11946 size_t cBackRefs = pMedium->i_getMachineBackRefCount();11947 Utf8Str strMediumLocation = pMedium->i_getLocationFull();11948 strMediumLocation.stripFilename();11949 Utf8Str strMachineFolder = i_getSettingsFileFull();11950 strMachineFolder.stripFilename();11951 11943 if ( ( cleanupMode == CleanupMode_DetachAllReturnHardDisksOnly 11952 11944 && devType == DeviceType_HardDisk) 11953 || ( cleanupMode == CleanupMode_DetachAllReturnHardDisksAndVMRemovable11954 && ( devType == DeviceType_HardDisk11955 || ( cBackRefs <= 111956 && strMediumLocation == strMachineFolder11957 && *pMedium->i_getFirstMachineBackrefId() == i_getId())))11958 11945 || (cleanupMode == CleanupMode_Full) 11959 11946 ) -
trunk/src/VBox/Main/src-server/MediumImpl.cpp
r97360 r97367 5528 5528 5529 5529 if ( !(m->formatObj->i_getCapabilities() & ( MediumFormatCapabilities_CreateDynamic 5530 | MediumFormatCapabilities_CreateFixed 5531 | MediumFormatCapabilities_File))) 5530 | MediumFormatCapabilities_CreateFixed))) 5532 5531 throw setError(VBOX_E_NOT_SUPPORTED, 5533 5532 tr("Medium format '%s' does not support storage deletion"), -
trunk/src/VBox/Main/src-server/UnattendedImpl.cpp
r97366 r97367 141 141 bool fMountOnly; 142 142 Utf8Str strImagePath; 143 bool fAuxiliary;144 143 145 144 UnattendedInstallationDisk(StorageBus_T a_enmBusType, Utf8Str const &a_rBusName, DeviceType_T a_enmDeviceType, 146 145 AccessMode_T a_enmAccessType, LONG a_iPort, LONG a_iDevice, bool a_fMountOnly, 147 Utf8Str const &a_rImagePath , bool a_fAuxiliary)146 Utf8Str const &a_rImagePath) 148 147 : enmBusType(a_enmBusType), strControllerName(a_rBusName), enmDeviceType(a_enmDeviceType), enmAccessType(a_enmAccessType) 149 , iPort(a_iPort), iDevice(a_iDevice), fMountOnly(a_fMountOnly), strImagePath(a_rImagePath) , fAuxiliary(a_fAuxiliary)148 , iPort(a_iPort), iDevice(a_iDevice), fMountOnly(a_fMountOnly), strImagePath(a_rImagePath) 150 149 { 151 150 Assert(strControllerName.length() > 0); 152 151 } 153 152 154 UnattendedInstallationDisk(std::list<ControllerSlot>::const_iterator const &itDvdSlot, Utf8Str const &a_rImagePath, 155 bool a_fAuxiliary) 153 UnattendedInstallationDisk(std::list<ControllerSlot>::const_iterator const &itDvdSlot, Utf8Str const &a_rImagePath) 156 154 : enmBusType(itDvdSlot->enmBus), strControllerName(itDvdSlot->strControllerName), enmDeviceType(DeviceType_DVD) 157 155 , enmAccessType(AccessMode_ReadOnly), iPort(itDvdSlot->iPort), iDevice(itDvdSlot->iDevice) 158 , fMountOnly(!itDvdSlot->fFree), strImagePath(a_rImagePath) , fAuxiliary(a_fAuxiliary)156 , fMountOnly(!itDvdSlot->fFree), strImagePath(a_rImagePath) 159 157 { 160 158 Assert(strControllerName.length() > 0); … … 3054 3052 0, 0, 3055 3053 fFoundPort0Dev0 /*fMountOnly*/, 3056 mpInstaller->getAuxiliaryFloppyFilePath() , false));3054 mpInstaller->getAuxiliaryFloppyFilePath())); 3057 3055 return S_OK; 3058 3056 } … … 3213 3211 if (mpInstaller->isAuxiliaryIsoNeeded() && mpInstaller->bootFromAuxiliaryIso()) 3214 3212 { 3215 rVecInstallatationDisks.push_back(UnattendedInstallationDisk(itDvdSlot, mpInstaller->getAuxiliaryIsoFilePath() , true));3213 rVecInstallatationDisks.push_back(UnattendedInstallationDisk(itDvdSlot, mpInstaller->getAuxiliaryIsoFilePath())); 3216 3214 ++itDvdSlot; 3217 3215 } … … 3219 3217 if (mpInstaller->isOriginalIsoNeeded()) 3220 3218 { 3221 rVecInstallatationDisks.push_back(UnattendedInstallationDisk(itDvdSlot, i_getIsoPath() , false));3219 rVecInstallatationDisks.push_back(UnattendedInstallationDisk(itDvdSlot, i_getIsoPath())); 3222 3220 ++itDvdSlot; 3223 3221 } … … 3225 3223 if (mpInstaller->isAuxiliaryIsoNeeded() && !mpInstaller->bootFromAuxiliaryIso()) 3226 3224 { 3227 rVecInstallatationDisks.push_back(UnattendedInstallationDisk(itDvdSlot, mpInstaller->getAuxiliaryIsoFilePath() , true));3225 rVecInstallatationDisks.push_back(UnattendedInstallationDisk(itDvdSlot, mpInstaller->getAuxiliaryIsoFilePath())); 3228 3226 ++itDvdSlot; 3229 3227 } … … 3232 3230 if (mpInstaller->isAdditionsIsoNeeded()) 3233 3231 { 3234 rVecInstallatationDisks.push_back(UnattendedInstallationDisk(itDvdSlot, i_getAdditionsIsoPath() , false));3232 rVecInstallatationDisks.push_back(UnattendedInstallationDisk(itDvdSlot, i_getAdditionsIsoPath())); 3235 3233 ++itDvdSlot; 3236 3234 } … … 3238 3236 if (mpInstaller->isValidationKitIsoNeeded()) 3239 3237 { 3240 rVecInstallatationDisks.push_back(UnattendedInstallationDisk(itDvdSlot, i_getValidationKitIsoPath() , false));3238 rVecInstallatationDisks.push_back(UnattendedInstallationDisk(itDvdSlot, i_getValidationKitIsoPath())); 3241 3239 ++itDvdSlot; 3242 3240 } … … 4209 4207 4210 4208 ComPtr<IMedium> ptrMedium; 4211 HRESULT hrc = mParent->OpenMedium(Bstr(pImage->strImagePath).raw(), 4212 pImage->enmDeviceType, 4213 pImage->enmAccessType, 4214 true, 4215 ptrMedium.asOutParam()); 4216 LogRelFlowFunc(("VirtualBox::openMedium -> %Rhrc\n", hrc)); 4217 if (SUCCEEDED(hrc)) 4218 { 4219 if (pImage->fAuxiliary && pImage->strImagePath.endsWith(".viso")) 4220 { 4221 hrc = ptrMedium->SetProperty(Bstr("UnattendedInstall").raw(), Bstr("1").raw()); 4222 LogRelFlowFunc(("Medium::SetProperty -> %Rhrc\n", hrc)); 4223 } 4224 4209 HRESULT rc = mParent->OpenMedium(Bstr(pImage->strImagePath).raw(), 4210 pImage->enmDeviceType, 4211 pImage->enmAccessType, 4212 true, 4213 ptrMedium.asOutParam()); 4214 LogRelFlowFunc(("VirtualBox::openMedium -> %Rhrc\n", rc)); 4215 if (SUCCEEDED(rc)) 4216 { 4225 4217 if (pImage->fMountOnly) 4226 4218 { 4227 4219 // mount the opened disk image 4228 hrc = rPtrSessionMachine->MountMedium(Bstr(pImage->strControllerName).raw(), pImage->iPort,4229 4230 LogRelFlowFunc(("Machine::MountMedium -> %Rhrc\n", hrc));4220 rc = rPtrSessionMachine->MountMedium(Bstr(pImage->strControllerName).raw(), pImage->iPort, 4221 pImage->iDevice, ptrMedium, TRUE /*fForce*/); 4222 LogRelFlowFunc(("Machine::MountMedium -> %Rhrc\n", rc)); 4231 4223 } 4232 4224 else 4233 4225 { 4234 4226 //attach the opened disk image to the controller 4235 hrc = rPtrSessionMachine->AttachDevice(Bstr(pImage->strControllerName).raw(), pImage->iPort,4236 4237 LogRelFlowFunc(("Machine::AttachDevice -> %Rhrc\n", hrc));4227 rc = rPtrSessionMachine->AttachDevice(Bstr(pImage->strControllerName).raw(), pImage->iPort, 4228 pImage->iDevice, pImage->enmDeviceType, ptrMedium); 4229 LogRelFlowFunc(("Machine::AttachDevice -> %Rhrc\n", rc)); 4238 4230 } 4239 4231 } 4240 4232 4241 4233 rLock.acquire(); 4242 return hrc;4234 return rc; 4243 4235 } 4244 4236 -
trunk/src/VBox/Storage/VISO.cpp
r97360 r97367 105 105 { "viso", VDTYPE_OPTICAL_DISC }, 106 106 { NULL, VDTYPE_INVALID } 107 };108 109 /** NULL-terminated array of configuration option. */110 static const VDCONFIGINFO s_aVisoConfigInfo[] =111 {112 /* Options for VMDK raw disks */113 { "UnattendedInstall", NULL, VDCFGVALUETYPE_STRING, VD_CFGKEY_EXPERT },114 /* End of options list */115 { NULL, NULL, VDCFGVALUETYPE_INTEGER, 0 }116 107 }; 117 108 … … 524 515 } 525 516 526 /** 527 * Scans the VISO file and removes all references to files 528 * which are in the same folder as the VISO and 529 * whose names begin with "Unattended-". 530 * 531 * @return VBox status code. 532 * 533 * @param pThis Pointer to VISO backend data. 534 */ 535 static int deleteReferences(PVISOIMAGE pThis) 536 { 537 /* 538 * Open the file and read it into memory. 539 */ 540 PVDIOSTORAGE pStorage = NULL; 541 int vrc = vdIfIoIntFileOpen(pThis->pIfIo, pThis->pszFilename, RTFILE_O_READ | RTFILE_O_OPEN | RTFILE_O_DENY_NONE, &pStorage); 542 if (RT_FAILURE(vrc)) 543 { 544 LogRel(("VISO: Unable to open file '%s': %Rrc\n", pThis->pszFilename, vrc)); 545 return vrc; 546 } 547 548 LogRel(("VISO: Handling file '%s' references\n", pThis->pszFilename)); 549 550 /* 551 * Read the file into memory. 552 */ 553 uint64_t cbFile = 0; 554 vrc = vdIfIoIntFileGetSize(pThis->pIfIo, pStorage, &cbFile); 555 if (RT_SUCCESS(vrc)) 556 { 557 if (cbFile <= VISO_MAX_FILE_SIZE) 558 { 559 char *pszContent = (char *)RTMemTmpAlloc(cbFile + 1); 560 if (pszContent) 561 { 562 vrc = vdIfIoIntFileReadSync(pThis->pIfIo, pStorage, 0 /*off*/, pszContent, (size_t)cbFile); 563 if (RT_SUCCESS(vrc)) 564 { 565 /* 566 * Check the file marker. 567 * Ignore leading blanks. 568 */ 569 pszContent[(size_t)cbFile] = '\0'; 570 571 char *pszReadDst = pszContent; 572 while (RT_C_IS_SPACE(*pszReadDst)) 573 pszReadDst++; 574 if (strncmp(pszReadDst, RT_STR_TUPLE("--iprt-iso-maker-file-marker")) == 0) 575 { 576 vrc = visoParseUuid(pszReadDst, &pThis->Uuid); 577 if (RT_SUCCESS(vrc)) 578 { 579 /* 580 * Make sure it's valid UTF-8 before letting 581 */ 582 vrc = RTStrValidateEncodingEx(pszContent, cbFile + 1, 583 RTSTR_VALIDATE_ENCODING_EXACT_LENGTH 584 | RTSTR_VALIDATE_ENCODING_ZERO_TERMINATED); 585 if (RT_SUCCESS(vrc)) 586 { 587 /* 588 * Convert it into an argument vector. 589 * Free the content afterwards to reduce memory pressure. 590 */ 591 uint32_t fGetOpt = strncmp(pszReadDst, RT_STR_TUPLE("--iprt-iso-maker-file-marker-ms")) != 0 592 ? RTGETOPTARGV_CNV_QUOTE_BOURNE_SH : RTGETOPTARGV_CNV_QUOTE_MS_CRT; 593 fGetOpt |= RTGETOPTARGV_CNV_MODIFY_INPUT; 594 char **papszArgs; 595 int cArgs; 596 vrc = RTGetOptArgvFromString(&papszArgs, &cArgs, pszContent, fGetOpt, NULL); 597 598 if (RT_SUCCESS(vrc)) 599 { 600 for (int i = 0; i < cArgs; ++i) 601 { 602 char *pszArg = papszArgs[i]; 603 char *pszOffset = strrchr(pszArg, '='); 604 if (pszOffset != NULL) 605 pszArg = pszOffset + 1; 606 607 /* if it isn't option */ 608 if (pszArg[0] != '-') 609 { 610 char *pszPath = RTPathAbsExDup(pThis->pszCwd, pszArg, 0); 611 if (RTStrStartsWith((const char *)pszPath, pThis->pszCwd)) 612 { 613 char *pszFileName = RTPathFilename(pszPath); 614 if ( pszFileName != NULL 615 && RTStrStartsWith((const char *)pszFileName, "Unattended-")) 616 { 617 vrc = RTFileDelete(pszPath); 618 if (RT_SUCCESS(vrc)) 619 LogRel(("VISO: file '%s' deleted\n", pszPath)); 620 else 621 LogRel(("VISO: Failed to delete the file '%s' (%Rrc)\n", pszPath, vrc)); 622 vrc = VINF_SUCCESS; 623 } 624 } 625 RTStrFree(pszPath); 626 } 627 } 628 RTGetOptArgvFreeEx(papszArgs, fGetOpt); 629 papszArgs = NULL; 630 } 631 else 632 vdIfError(pThis->pIfError, vrc, RT_SRC_POS, "VISO: RTGetOptArgvFromString failed: %Rrc", vrc); 633 } 634 else 635 vdIfError(pThis->pIfError, vrc, RT_SRC_POS, "VISO: Invalid file encoding"); 636 } 637 else 638 vdIfError(pThis->pIfError, vrc, RT_SRC_POS, "VISO: Parsing UUID failed: %Rrc", vrc); 639 } 640 else 641 vrc = VERR_VD_GEN_INVALID_HEADER; 642 } 643 else 644 vdIfError(pThis->pIfError, vrc, RT_SRC_POS, "VISO: Reading file failed: %Rrc", vrc); 645 646 RTMemTmpFree(pszContent); 647 } 648 else 649 vrc = VERR_NO_TMP_MEMORY; 650 } 651 else 652 { 653 LogRel(("visoOpen: VERR_VD_INVALID_SIZE - cbFile=%#RX64 cbMaxFile=%#RX64\n", 654 cbFile, (uint64_t)VISO_MAX_FILE_SIZE)); 655 vrc = VERR_VD_INVALID_SIZE; 656 } 657 } 658 659 if (RT_FAILURE(vrc)) 660 LogRel(("VISO: Handling of file '%s' failed with %Rrc\n", pThis->pszFilename, vrc)); 661 662 vdIfIoIntFileClose(pThis->pIfIo, pStorage); 663 return vrc; 664 } 665 666 /** 667 * @interface_method_impl{VDIMAGEBACKEND,pfnClose} 517 518 /** 519 * @interface_method_impl{VDIMAGEBACKEND,pfnClose} 668 520 */ 669 521 static DECLCALLBACK(int) visoClose(void *pBackendData, bool fDelete) … … 675 527 { 676 528 if (fDelete) 677 {678 PVDINTERFACECONFIG pImgCfg = VDIfConfigGet(&pThis->pIfIo->Core);679 680 bool fUnattendedInstall = false;681 int vrc = VDCFGQueryBool(pImgCfg, "UnattendedInstall", &fUnattendedInstall);682 683 /*684 * The VISO created by unattended installer, so delete all generated files685 * included in the VISO. the file is considered generated if it is located686 * in the same folder as VISO and its name begins with "Unattended-"687 */688 if (RT_SUCCESS(vrc) && fUnattendedInstall)689 deleteReferences(pThis);690 529 vdIfIoIntFileDelete(pThis->pIfIo, pThis->pszFilename); 691 }692 530 693 531 if (pThis->hIsoFile != NIL_RTVFSFILE) … … 1031 869 g_aVBoXIsoMakerFileExtensions, 1032 870 /* paConfigInfo */ 1033 s_aVisoConfigInfo,871 NULL, 1034 872 /* pfnProbe */ 1035 873 visoProbe,
Note:
See TracChangeset
for help on using the changeset viewer.