VirtualBox

Changeset 98035 in vbox for trunk/src/VBox/Main


Ignore:
Timestamp:
Jan 10, 2023 6:35:56 AM (2 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
155131
Message:

reimplemented changes for bugref:10180 after seperating the changes from bugref:4787

Location:
trunk/src/VBox/Main
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Main/idl/VirtualBox.xidl

    r97935 r98035  
    65236523    <desc>Cleanup mode, used with <link to="IMachine::unregister" />.
    65246524    </desc>
    6525     <const name="UnregisterOnly"                  value="1">
     6525    <const name="UnregisterOnly"                          value="1">
    65266526      <desc>Unregister only the machine, but neither delete snapshots nor detach media.</desc>
    65276527    </const>
    6528     <const name="DetachAllReturnNone"             value="2">
     6528    <const name="DetachAllReturnNone"                     value="2">
    65296529      <desc>Delete all snapshots and detach all media but return none; this will keep all media registered.</desc>
    65306530    </const>
    6531     <const name="DetachAllReturnHardDisksOnly"    value="3">
     6531    <const name="DetachAllReturnHardDisksOnly"            value="3">
    65326532      <desc>Delete all snapshots, detach all media and return hard disks for closing, but not removable media.</desc>
    65336533    </const>
    6534     <const name="Full"                            value="4">
     6534    <const name="Full"                                    value="4">
    65356535      <desc>Delete all snapshots, detach all media and return all media for closing.</desc>
     6536    </const>
     6537    <const name="DetachAllReturnHardDisksAndVMRemovable"  value="5">
     6538      <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>
    65366539    </const>
    65376540  </enum>
  • trunk/src/VBox/Main/src-server/MachineImpl.cpp

    r97523 r98035  
    1189711897 * adds hard disks to the list. If it is CleanupMode_Full, this adds all
    1189811898 * media to the list.
     11899 * CleanupMode_DetachAllReturnHardDisksAndVMRemovable adds hard disk and
     11900 * also removable medias if they are located in the VM folder and referenced
     11901 * only by this VM (media prepared by unattended installer).
    1189911902 *
    1190011903 * This gets called from Machine::Unregister, both for the actual Machine and
     
    1194211945            AutoReadLock lock(pMedium COMMA_LOCKVAL_SRC_POS);
    1194311946            DeviceType_T devType = pMedium->i_getDeviceType();
     11947            size_t cBackRefs = pMedium->i_getMachineBackRefCount();
     11948            Utf8Str strMediumLocation = pMedium->i_getLocationFull();
     11949            strMediumLocation.stripFilename();
     11950            Utf8Str strMachineFolder =  i_getSettingsFileFull();
     11951            strMachineFolder.stripFilename();
    1194411952            if (    (    cleanupMode == CleanupMode_DetachAllReturnHardDisksOnly
    1194511953                      && devType == DeviceType_HardDisk)
     11954                 || (    cleanupMode == CleanupMode_DetachAllReturnHardDisksAndVMRemovable
     11955                      && (    devType == DeviceType_HardDisk
     11956                           || (    cBackRefs <= 1
     11957                                && strMediumLocation == strMachineFolder
     11958                                && *pMedium->i_getFirstMachineBackrefId() == i_getId())))
    1194611959                 || (cleanupMode == CleanupMode_Full)
    1194711960               )
  • trunk/src/VBox/Main/src-server/MediumImpl.cpp

    r97935 r98035  
    10611061
    10621062    if (!(m->formatObj->i_getCapabilities() & (  MediumFormatCapabilities_CreateFixed
    1063                                                | MediumFormatCapabilities_CreateDynamic))
     1063                                               | MediumFormatCapabilities_CreateDynamic
     1064                                               | MediumFormatCapabilities_File))
    10641065       )
    10651066    {
  • trunk/src/VBox/Main/src-server/UnattendedImpl.cpp

    r97367 r98035  
    141141    bool            fMountOnly;
    142142    Utf8Str         strImagePath;
     143    bool            fAuxiliary;
    143144
    144145    UnattendedInstallationDisk(StorageBus_T a_enmBusType, Utf8Str const &a_rBusName, DeviceType_T a_enmDeviceType,
    145146                               AccessMode_T a_enmAccessType, LONG a_iPort, LONG a_iDevice, bool a_fMountOnly,
    146                                Utf8Str const &a_rImagePath)
     147                               Utf8Str const &a_rImagePath, bool a_fAuxiliary)
    147148        : enmBusType(a_enmBusType), strControllerName(a_rBusName), enmDeviceType(a_enmDeviceType), enmAccessType(a_enmAccessType)
    148         , iPort(a_iPort), iDevice(a_iDevice), fMountOnly(a_fMountOnly), strImagePath(a_rImagePath)
     149        , iPort(a_iPort), iDevice(a_iDevice), fMountOnly(a_fMountOnly), strImagePath(a_rImagePath), fAuxiliary(a_fAuxiliary)
    149150    {
    150151        Assert(strControllerName.length() > 0);
    151152    }
    152153
    153     UnattendedInstallationDisk(std::list<ControllerSlot>::const_iterator const &itDvdSlot, Utf8Str const &a_rImagePath)
     154    UnattendedInstallationDisk(std::list<ControllerSlot>::const_iterator const &itDvdSlot, Utf8Str const &a_rImagePath,
     155                               bool a_fAuxiliary)
    154156        : enmBusType(itDvdSlot->enmBus), strControllerName(itDvdSlot->strControllerName), enmDeviceType(DeviceType_DVD)
    155157        , enmAccessType(AccessMode_ReadOnly), iPort(itDvdSlot->iPort), iDevice(itDvdSlot->iDevice)
    156         , fMountOnly(!itDvdSlot->fFree), strImagePath(a_rImagePath)
     158        , fMountOnly(!itDvdSlot->fFree), strImagePath(a_rImagePath), fAuxiliary(a_fAuxiliary)
    157159    {
    158160        Assert(strControllerName.length() > 0);
     
    30523054                                                                 0, 0,
    30533055                                                                 fFoundPort0Dev0 /*fMountOnly*/,
    3054                                                                  mpInstaller->getAuxiliaryFloppyFilePath()));
     3056                                                                 mpInstaller->getAuxiliaryFloppyFilePath(), false));
    30553057    return S_OK;
    30563058}
     
    32113213    if (mpInstaller->isAuxiliaryIsoNeeded() && mpInstaller->bootFromAuxiliaryIso())
    32123214    {
    3213         rVecInstallatationDisks.push_back(UnattendedInstallationDisk(itDvdSlot, mpInstaller->getAuxiliaryIsoFilePath()));
     3215        rVecInstallatationDisks.push_back(UnattendedInstallationDisk(itDvdSlot, mpInstaller->getAuxiliaryIsoFilePath(), true));
    32143216        ++itDvdSlot;
    32153217    }
     
    32173219    if (mpInstaller->isOriginalIsoNeeded())
    32183220    {
    3219         rVecInstallatationDisks.push_back(UnattendedInstallationDisk(itDvdSlot, i_getIsoPath()));
     3221        rVecInstallatationDisks.push_back(UnattendedInstallationDisk(itDvdSlot, i_getIsoPath(), false));
    32203222        ++itDvdSlot;
    32213223    }
     
    32233225    if (mpInstaller->isAuxiliaryIsoNeeded() && !mpInstaller->bootFromAuxiliaryIso())
    32243226    {
    3225         rVecInstallatationDisks.push_back(UnattendedInstallationDisk(itDvdSlot, mpInstaller->getAuxiliaryIsoFilePath()));
     3227        rVecInstallatationDisks.push_back(UnattendedInstallationDisk(itDvdSlot, mpInstaller->getAuxiliaryIsoFilePath(), true));
    32263228        ++itDvdSlot;
    32273229    }
     
    32303232    if (mpInstaller->isAdditionsIsoNeeded())
    32313233    {
    3232         rVecInstallatationDisks.push_back(UnattendedInstallationDisk(itDvdSlot, i_getAdditionsIsoPath()));
     3234        rVecInstallatationDisks.push_back(UnattendedInstallationDisk(itDvdSlot, i_getAdditionsIsoPath(), false));
    32333235        ++itDvdSlot;
    32343236    }
     
    32363238    if (mpInstaller->isValidationKitIsoNeeded())
    32373239    {
    3238         rVecInstallatationDisks.push_back(UnattendedInstallationDisk(itDvdSlot, i_getValidationKitIsoPath()));
     3240        rVecInstallatationDisks.push_back(UnattendedInstallationDisk(itDvdSlot, i_getValidationKitIsoPath(), false));
    32393241        ++itDvdSlot;
    32403242    }
     
    42074209
    42084210    ComPtr<IMedium> ptrMedium;
    4209     HRESULT rc = mParent->OpenMedium(Bstr(pImage->strImagePath).raw(),
     4211    HRESULT hrc = mParent->OpenMedium(Bstr(pImage->strImagePath).raw(),
    42104212                                     pImage->enmDeviceType,
    42114213                                     pImage->enmAccessType,
    42124214                                     true,
    42134215                                     ptrMedium.asOutParam());
    4214     LogRelFlowFunc(("VirtualBox::openMedium -> %Rhrc\n", rc));
    4215     if (SUCCEEDED(rc))
    4216     {
     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        }
    42174224        if (pImage->fMountOnly)
    42184225        {
    42194226            // mount the opened disk image
    4220             rc = rPtrSessionMachine->MountMedium(Bstr(pImage->strControllerName).raw(), pImage->iPort,
    4221                                                  pImage->iDevice, ptrMedium, TRUE /*fForce*/);
    4222             LogRelFlowFunc(("Machine::MountMedium -> %Rhrc\n", rc));
     4227            hrc = rPtrSessionMachine->MountMedium(Bstr(pImage->strControllerName).raw(), pImage->iPort,
     4228                                                  pImage->iDevice, ptrMedium, TRUE /*fForce*/);
     4229            LogRelFlowFunc(("Machine::MountMedium -> %Rhrc\n", hrc));
    42234230        }
    42244231        else
    42254232        {
    42264233            //attach the opened disk image to the controller
    4227             rc = rPtrSessionMachine->AttachDevice(Bstr(pImage->strControllerName).raw(), pImage->iPort,
    4228                                                   pImage->iDevice, pImage->enmDeviceType, ptrMedium);
    4229             LogRelFlowFunc(("Machine::AttachDevice -> %Rhrc\n", rc));
     4234            hrc = rPtrSessionMachine->AttachDevice(Bstr(pImage->strControllerName).raw(), pImage->iPort,
     4235                                                   pImage->iDevice, pImage->enmDeviceType, ptrMedium);
     4236            LogRelFlowFunc(("Machine::AttachDevice -> %Rhrc\n", hrc));
    42304237        }
    42314238    }
    42324239
    42334240    rLock.acquire();
    4234     return rc;
     4241    return hrc;
    42354242}
    42364243
Note: See TracChangeset for help on using the changeset viewer.

© 2025 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette