VirtualBox

儲存庫 vbox 的更動 67611


忽略:
時間撮記:
2017-6-26 下午04:06:53 (7 年 以前)
作者:
vboxsync
訊息:

FE/Qt: Runtime UI: Rework GA image mounting to use smart ad-hoc medium mounting (s.a. r116373).

檔案:
修改 1 筆資料

圖例:

未更動
新增
刪除
  • trunk/src/VBox/Frontends/VirtualBox/src/runtime/UISession.cpp

    r67610 r67611  
    539539    bool fDoMount = false;
    540540
    541     /* Auto-update in GUI currently is disabled. */
     541    /* Auto-update through GUI is currently disabled. */
    542542#ifndef VBOX_WITH_ADDITIONS_AUTOUPDATE_UI
    543543    fDoMount = true;
    544544#else /* VBOX_WITH_ADDITIONS_AUTOUPDATE_UI */
     545    /* Initiate installation progress: */
     546    QVector<QString> aArgs;
    545547    QVector<KAdditionsUpdateFlag> aFlagsUpdate;
    546     QVector<QString> aArgs;
    547     CProgress progressInstall = guest().UpdateGuestAdditions(strSource,
    548                                                              aArgs, aFlagsUpdate);
    549     bool fResult = guest().isOk();
    550     if (fResult)
    551     {
    552         msgCenter().showModalProgressDialog(progressInstall, tr("Updating Guest Additions"),
     548    CProgress comProgressInstall = guest().UpdateGuestAdditions(strSource, aArgs, aFlagsUpdate);
     549    if (guest().isOk() && comProgressInstall.isNotNull())
     550    {
     551        /* Show installation progress: */
     552        msgCenter().showModalProgressDialog(comProgressInstall, tr("Updating Guest Additions"),
    553553                                            ":/progress_install_guest_additions_90px.png",
    554554                                            0, 500 /* 500ms delay. */);
    555         if (progressInstall.GetCanceled())
     555        if (comProgressInstall.GetCanceled())
    556556            return;
    557557
    558         HRESULT rc = progressInstall.GetResultCode();
    559         if (!progressInstall.isOk() || rc != S_OK)
    560         {
    561             /* If we got back a VBOX_E_NOT_SUPPORTED we don't complain (guest OS
    562              * simply isn't supported yet), so silently fall back to "old" .ISO
    563              * mounting method. */
     558        /* Check whether progress result isn't Ok: */
     559        const HRESULT rc = comProgressInstall.GetResultCode();
     560        if (!comProgressInstall.isOk() || rc != S_OK)
     561        {
     562            /* If we got back a VBOX_E_NOT_SUPPORTED we don't complain (guest OS simply isn't
     563             * supported yet), so silently fall back to "old" .ISO mounting method. */
    564564            if (   !SUCCEEDED_WARNING(rc)
    565565                && rc != VBOX_E_NOT_SUPPORTED)
    566566            {
    567                 msgCenter().cannotUpdateGuestAdditions(progressInstall);
    568 
    569                 /* Log the error message in the release log. */
    570                 QString strErr = progressInstall.GetErrorInfo().GetText();
     567                msgCenter().cannotUpdateGuestAdditions(comProgressInstall);
     568
     569                /* Throw the error message into release log as well: */
     570                const QString &strErr = comProgressInstall.GetErrorInfo().GetText();
    571571                if (!strErr.isEmpty())
    572572                    LogRel(("%s\n", strErr.toLatin1().constData()));
    573573            }
    574             fDoMount = true; /* Since automatic updating failed, fall back to .ISO mounting. */
     574
     575            /* Since automatic updating failed, fall back to .ISO mounting: */
     576            fDoMount = true;
    575577        }
    576578    }
    577579#endif /* VBOX_WITH_ADDITIONS_AUTOUPDATE_UI */
    578580
    579     /* Do we still want mounting? */
     581    /* Check whether we still want mounting? */
    580582    if (!fDoMount)
    581583        return;
    582584
    583     /* Open corresponding medium: */
    584     QString strMediumID;
    585     CVirtualBox vbox = vboxGlobal().virtualBox();
    586     CMedium image = vbox.OpenMedium(strSource, KDeviceType_DVD, KAccessMode_ReadWrite, false /* fForceNewUuid */);
    587     if (vbox.isOk() && !image.isNull())
    588         strMediumID = image.GetId();
    589     else
    590     {
    591         msgCenter().cannotOpenMedium(vbox, UIMediumType_DVD, strSource, mainMachineWindow());
    592         return;
    593     }
    594 
    595     /* Make sure GA medium ID is valid: */
    596     AssertReturnVoid(!strMediumID.isNull());
    597 
    598     /* Search for a suitable storage slots: */
    599     QList<ExactStorageSlot> freeStorageSlots;
    600     QList<ExactStorageSlot> busyStorageSlots;
    601     foreach (const CStorageController &controller, machine().GetStorageControllers())
    602     {
    603         foreach (const CMediumAttachment &attachment, machine().GetMediumAttachmentsOfController(controller.GetName()))
    604         {
    605             /* Look for an optical device: */
    606             if (attachment.GetType() == KDeviceType_DVD)
    607             {
    608                 /* Append storage slot to corresponding list: */
    609                 if (attachment.GetMedium().isNull())
    610                     freeStorageSlots << ExactStorageSlot(controller.GetName(), controller.GetBus(),
    611                                                          attachment.GetPort(), attachment.GetDevice());
    612                 else
    613                     busyStorageSlots << ExactStorageSlot(controller.GetName(), controller.GetBus(),
    614                                                          attachment.GetPort(), attachment.GetDevice());
    615             }
    616         }
    617     }
    618 
    619     /* Make sure at least one storage slot found: */
    620     QList<ExactStorageSlot> storageSlots = freeStorageSlots + busyStorageSlots;
    621     if (storageSlots.isEmpty())
    622     {
    623         msgCenter().cannotMountGuestAdditions(machineName());
    624         return;
    625     }
    626 
    627     /* Try to find UIMedium among cached: */
    628     UIMedium medium = vboxGlobal().medium(strMediumID);
    629     if (medium.isNull())
    630     {
    631         /* Create new one if necessary: */
    632         medium = UIMedium(image, UIMediumType_DVD, KMediumState_Created);
    633         vboxGlobal().createMedium(medium);
    634     }
    635 
    636     /* Try to mount medium to first storage slot: */
    637     bool fMounted = false;
    638     while (!storageSlots.isEmpty() && !fMounted)
    639     {
    640         const ExactStorageSlot storageSlot = storageSlots.takeFirst();
    641         machine().MountMedium(storageSlot.controller, storageSlot.port, storageSlot.device, medium.medium(), false /* force */);
    642         if (machine().isOk())
    643             fMounted = true;
    644     }
    645     if (!machine().isOk())
    646     {
    647         msgCenter().cannotRemountMedium(machine(), medium, true /* mount? */,
    648                                         false /* retry? */, mainMachineWindow());
    649     }
     585    /* Mount medium add-hoc: */
     586    mountAdHocImage(KDeviceType_DVD, UIMediumType_DVD, strSource);
    650587}
    651588
注意: 瀏覽 TracChangeset 來幫助您使用更動檢視器

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