VirtualBox

Changeset 73589 in vbox for trunk/src/VBox


Ignore:
Timestamp:
Aug 9, 2018 1:56:15 PM (6 years ago)
Author:
vboxsync
Message:

Main: Allow changing the passthrough flag when the VM is running if the storage controller supports hot plugging

Location:
trunk/src/VBox
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Devices/Storage/DrvSCSI.cpp

    r73097 r73589  
    12301230
    12311231    LogFlowFunc(("pDrvIns=%#p fFlags=%#x\n", pDrvIns, fFlags));
    1232 
    1233     AssertMsgReturnVoid((fFlags & PDM_TACH_FLAGS_NOT_HOT_PLUG),
    1234                         ("SCSI: Hotplugging is not supported\n"));
    12351232
    12361233    /*
  • trunk/src/VBox/Main/src-server/MachineImpl.cpp

    r73003 r73589  
    45074507    AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS);
    45084508
    4509     HRESULT rc = i_checkStateDependency(MutableStateDep);
     4509    HRESULT rc = i_checkStateDependency(MutableOrRunningStateDep);
    45104510    if (FAILED(rc)) return rc;
    45114511
    45124512    AssertReturn(mData->mMachineState != MachineState_Saved, E_FAIL);
    45134513
    4514     if (Global::IsOnlineOrTransient(mData->mMachineState))
     4514    /* Check for an existing controller. */
     4515    ComObjPtr<StorageController> ctl;
     4516    rc = i_getStorageControllerByName(aName, ctl, true /* aSetError */);
     4517    if (FAILED(rc)) return rc;
     4518
     4519    StorageControllerType_T ctrlType;
     4520    rc = ctl->COMGETTER(ControllerType)(&ctrlType);
     4521    if (FAILED(rc))
     4522        return setError(E_FAIL,
     4523                        tr("Could not get type of controller '%s'"),
     4524                        aName.c_str());
     4525
     4526    bool fSilent = false;
     4527    Utf8Str strReconfig;
     4528
     4529    /* Check whether the flag to allow silent storage attachment reconfiguration is set. */
     4530    strReconfig = i_getExtraData(Utf8Str("VBoxInternal2/SilentReconfigureWhilePaused"));
     4531    if (   mData->mMachineState == MachineState_Paused
     4532        && strReconfig == "1")
     4533        fSilent = true;
     4534
     4535    /* Check that the controller can do hotplugging if we detach the device while the VM is running. */
     4536    bool fHotplug = false;
     4537    if (!fSilent && Global::IsOnlineOrTransient(mData->mMachineState))
     4538        fHotplug = true;
     4539
     4540    if (fHotplug && !i_isControllerHotplugCapable(ctrlType))
    45154541        return setError(VBOX_E_INVALID_VM_STATE,
    4516                         tr("Invalid machine state: %s"),
    4517                         Global::stringifyMachineState(mData->mMachineState));
     4542                        tr("Controller '%s' does not support hotplugging which is required to change the passthrough setting while the VM is running"),
     4543                        aName.c_str());
    45184544
    45194545    MediumAttachment *pAttach = i_findAttachment(*mMediumAttachments.data(),
     
    45384564    pAttach->i_updatePassthrough(!!aPassthrough);
    45394565
    4540     return S_OK;
     4566    attLock.release();
     4567    alock.release();
     4568    rc = i_onStorageDeviceChange(pAttach, FALSE /* aRemove */, FALSE /* aSilent */);
     4569
     4570    return rc;
    45414571}
    45424572
Note: See TracChangeset for help on using the changeset viewer.

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