VirtualBox

Changeset 97367 in vbox


Ignore:
Timestamp:
Nov 1, 2022 10:38:05 AM (2 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
154365
Message:

Backed out r154357,r154358,r154360,r154361,r154364 because it still doesn't build, old files weren't renamed or removed, and the changes for bugref:10180 and bugref:4787 got mixed up, making it difficult to selectively revert the latter one only.

Location:
trunk
Files:
8 edited

Legend:

Unmodified
Added
Removed
  • trunk/doc/manual/en_US/man_VBoxManage-unregistervm.xml

    r97360 r97367  
    5555      </group>
    5656      <arg>--delete</arg>
    57       <arg>--delete-all</arg>
    5857    </cmdsynopsis>
    5958  </refsynopsisdiv>
     
    9695          </itemizedlist></listitem>
    9796      </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 and
    103             attached only to this VM.
    104           </para></listitem>
    105       </varlistentry>
    10697    </variablelist>
    10798  </refsect1>
  • trunk/src/VBox/Frontends/VBoxManage/VBoxManageMisc.cpp

    r97360 r97367  
    171171    { "--delete",       'd', RTGETOPT_REQ_NOTHING },
    172172    { "-delete",        'd', RTGETOPT_REQ_NOTHING },    // deprecated
    173     { "--delete-all",   'a', RTGETOPT_REQ_NOTHING },
    174     { "-delete-all",    'a', RTGETOPT_REQ_NOTHING },    // deprecated
    175173};
    176174
     
    180178    const char *VMName = NULL;
    181179    bool fDelete = false;
    182     bool fDeleteAll = false;
    183180
    184181    int c;
     
    194191            case 'd':   // --delete
    195192                fDelete = true;
    196                 break;
    197 
    198             case 'a':   // --delete-all
    199                 fDeleteAll = true;
    200193                break;
    201194
     
    231224                    RTEXITCODE_FAILURE);
    232225    SafeIfaceArray<IMedium> aMedia;
    233     CHECK_ERROR_RET(machine, Unregister(fDeleteAll ? CleanupMode_DetachAllReturnHardDisksAndVMRemovable
    234                                                    :CleanupMode_DetachAllReturnHardDisksOnly,
     226    CHECK_ERROR_RET(machine, Unregister(CleanupMode_DetachAllReturnHardDisksOnly,
    235227                                        ComSafeArrayAsOutParam(aMedia)),
    236228                    RTEXITCODE_FAILURE);
    237     if (fDelete || fDeleteAll)
     229    if (fDelete)
    238230    {
    239231        ComPtr<IProgress> pProgress;
  • trunk/src/VBox/Main/idl/VirtualBox.xidl

    r97360 r97367  
    65176517  <enum
    65186518    name="CleanupMode"
    6519     uuid="1ec1df9e-9b0e-43cd-ad4d-a34e10edb0c5"
     6519    uuid="67897c50-7cca-47a9-83f6-ce8fd8eb5441"
    65206520    >
    65216521    <desc>Cleanup mode, used with <link to="IMachine::unregister" />.
    65226522    </desc>
    6523     <const name="UnregisterOnly"                          value="1">
     6523    <const name="UnregisterOnly"                  value="1">
    65246524      <desc>Unregister only the machine, but neither delete snapshots nor detach media.</desc>
    65256525    </const>
    6526     <const name="DetachAllReturnNone"                     value="2">
     6526    <const name="DetachAllReturnNone"             value="2">
    65276527      <desc>Delete all snapshots and detach all media but return none; this will keep all media registered.</desc>
    65286528    </const>
    6529     <const name="DetachAllReturnHardDisksOnly"            value="3">
     6529    <const name="DetachAllReturnHardDisksOnly"    value="3">
    65306530      <desc>Delete all snapshots, detach all media and return hard disks for closing, but not removable media.</desc>
    65316531    </const>
    6532     <const name="Full"                                    value="4">
     6532    <const name="Full"                            value="4">
    65336533      <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>
    65376534    </const>
    65386535  </enum>
  • trunk/src/VBox/Main/src-client/ConsoleImpl.cpp

    r97359 r97367  
    6868#include "USBDeviceImpl.h"
    6969#include "RemoteUSBDeviceImpl.h"
    70 #include "ConsoleSharedFolderImpl.h"
     70#include "SharedFolderImpl.h"
    7171#ifdef VBOX_WITH_AUDIO_VRDE
    7272# include "DrvAudioVRDE.h"
  • trunk/src/VBox/Main/src-server/MachineImpl.cpp

    r97359 r97367  
    4949#include "USBDeviceFiltersImpl.h"
    5050#include "HostImpl.h"
    51 #include "MachineSharedFolderImpl.h"
     51#include "SharedFolderImpl.h"
    5252#include "GuestOSTypeImpl.h"
    5353#include "VirtualBoxErrorInfoImpl.h"
     
    1189611896 * adds hard disks to the list. If it is CleanupMode_Full, this adds all
    1189711897 * media to the list.
    11898  * CleanupMode_DetachAllReturnHardDisksAndVMRemovable adds hard disk and
    11899  * also removable medias if they are located in the VM folder and referenced
    11900  * only by this VM (media prepared by unattended installer).
    1190111898 *
    1190211899 * This gets called from Machine::Unregister, both for the actual Machine and
     
    1194411941            AutoReadLock lock(pMedium COMMA_LOCKVAL_SRC_POS);
    1194511942            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();
    1195111943            if (    (    cleanupMode == CleanupMode_DetachAllReturnHardDisksOnly
    1195211944                      && devType == DeviceType_HardDisk)
    11953                  || (    cleanupMode == CleanupMode_DetachAllReturnHardDisksAndVMRemovable
    11954                       && (    devType == DeviceType_HardDisk
    11955                            || (    cBackRefs <= 1
    11956                                 && strMediumLocation == strMachineFolder
    11957                                 && *pMedium->i_getFirstMachineBackrefId() == i_getId())))
    1195811945                 || (cleanupMode == CleanupMode_Full)
    1195911946               )
  • trunk/src/VBox/Main/src-server/MediumImpl.cpp

    r97360 r97367  
    55285528
    55295529        if (    !(m->formatObj->i_getCapabilities() & (  MediumFormatCapabilities_CreateDynamic
    5530                                                        | MediumFormatCapabilities_CreateFixed
    5531                                                        | MediumFormatCapabilities_File)))
     5530                                                       | MediumFormatCapabilities_CreateFixed)))
    55325531            throw setError(VBOX_E_NOT_SUPPORTED,
    55335532                           tr("Medium format '%s' does not support storage deletion"),
  • trunk/src/VBox/Main/src-server/UnattendedImpl.cpp

    r97366 r97367  
    141141    bool            fMountOnly;
    142142    Utf8Str         strImagePath;
    143     bool            fAuxiliary;
    144143
    145144    UnattendedInstallationDisk(StorageBus_T a_enmBusType, Utf8Str const &a_rBusName, DeviceType_T a_enmDeviceType,
    146145                               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)
    148147        : 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)
    150149    {
    151150        Assert(strControllerName.length() > 0);
    152151    }
    153152
    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)
    156154        : enmBusType(itDvdSlot->enmBus), strControllerName(itDvdSlot->strControllerName), enmDeviceType(DeviceType_DVD)
    157155        , 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)
    159157    {
    160158        Assert(strControllerName.length() > 0);
     
    30543052                                                                 0, 0,
    30553053                                                                 fFoundPort0Dev0 /*fMountOnly*/,
    3056                                                                  mpInstaller->getAuxiliaryFloppyFilePath(), false));
     3054                                                                 mpInstaller->getAuxiliaryFloppyFilePath()));
    30573055    return S_OK;
    30583056}
     
    32133211    if (mpInstaller->isAuxiliaryIsoNeeded() && mpInstaller->bootFromAuxiliaryIso())
    32143212    {
    3215         rVecInstallatationDisks.push_back(UnattendedInstallationDisk(itDvdSlot, mpInstaller->getAuxiliaryIsoFilePath(), true));
     3213        rVecInstallatationDisks.push_back(UnattendedInstallationDisk(itDvdSlot, mpInstaller->getAuxiliaryIsoFilePath()));
    32163214        ++itDvdSlot;
    32173215    }
     
    32193217    if (mpInstaller->isOriginalIsoNeeded())
    32203218    {
    3221         rVecInstallatationDisks.push_back(UnattendedInstallationDisk(itDvdSlot, i_getIsoPath(), false));
     3219        rVecInstallatationDisks.push_back(UnattendedInstallationDisk(itDvdSlot, i_getIsoPath()));
    32223220        ++itDvdSlot;
    32233221    }
     
    32253223    if (mpInstaller->isAuxiliaryIsoNeeded() && !mpInstaller->bootFromAuxiliaryIso())
    32263224    {
    3227         rVecInstallatationDisks.push_back(UnattendedInstallationDisk(itDvdSlot, mpInstaller->getAuxiliaryIsoFilePath(), true));
     3225        rVecInstallatationDisks.push_back(UnattendedInstallationDisk(itDvdSlot, mpInstaller->getAuxiliaryIsoFilePath()));
    32283226        ++itDvdSlot;
    32293227    }
     
    32323230    if (mpInstaller->isAdditionsIsoNeeded())
    32333231    {
    3234         rVecInstallatationDisks.push_back(UnattendedInstallationDisk(itDvdSlot, i_getAdditionsIsoPath(), false));
     3232        rVecInstallatationDisks.push_back(UnattendedInstallationDisk(itDvdSlot, i_getAdditionsIsoPath()));
    32353233        ++itDvdSlot;
    32363234    }
     
    32383236    if (mpInstaller->isValidationKitIsoNeeded())
    32393237    {
    3240         rVecInstallatationDisks.push_back(UnattendedInstallationDisk(itDvdSlot, i_getValidationKitIsoPath(), false));
     3238        rVecInstallatationDisks.push_back(UnattendedInstallationDisk(itDvdSlot, i_getValidationKitIsoPath()));
    32413239        ++itDvdSlot;
    32423240    }
     
    42094207
    42104208    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    {
    42254217        if (pImage->fMountOnly)
    42264218        {
    42274219            // mount the opened disk image
    4228             hrc = rPtrSessionMachine->MountMedium(Bstr(pImage->strControllerName).raw(), pImage->iPort,
    4229                                                   pImage->iDevice, ptrMedium, TRUE /*fForce*/);
    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));
    42314223        }
    42324224        else
    42334225        {
    42344226            //attach the opened disk image to the controller
    4235             hrc = rPtrSessionMachine->AttachDevice(Bstr(pImage->strControllerName).raw(), pImage->iPort,
    4236                                                    pImage->iDevice, pImage->enmDeviceType, ptrMedium);
    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));
    42384230        }
    42394231    }
    42404232
    42414233    rLock.acquire();
    4242     return hrc;
     4234    return rc;
    42434235}
    42444236
  • trunk/src/VBox/Storage/VISO.cpp

    r97360 r97367  
    105105    { "viso",           VDTYPE_OPTICAL_DISC },
    106106    { 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 }
    116107};
    117108
     
    524515}
    525516
    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}
    668520 */
    669521static DECLCALLBACK(int) visoClose(void *pBackendData, bool fDelete)
     
    675527    {
    676528        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 files
    685             * included in the VISO. the file is considered generated if it is located
    686             * in the same folder as VISO and its name begins with "Unattended-"
    687             */
    688             if (RT_SUCCESS(vrc) && fUnattendedInstall)
    689                 deleteReferences(pThis);
    690529            vdIfIoIntFileDelete(pThis->pIfIo, pThis->pszFilename);
    691         }
    692530
    693531        if (pThis->hIsoFile != NIL_RTVFSFILE)
     
    1031869    g_aVBoXIsoMakerFileExtensions,
    1032870    /* paConfigInfo */
    1033     s_aVisoConfigInfo,
     871    NULL,
    1034872    /* pfnProbe */
    1035873    visoProbe,
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