VirtualBox

Changeset 23928 in vbox


Ignore:
Timestamp:
Oct 21, 2009 10:17:08 AM (15 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
53737
Message:

API: make necessary adjustments to support DVD passthrough again, together with the necessary client code changes. Unfortunately it is not possible to define the API in the ideal way due to how settings are handled in MachineImpl.cpp.

Location:
trunk/src/VBox
Files:
8 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Frontends/VBoxManage/VBoxManageModifyVM.cpp

    r23873 r23928  
    10121012            case MODIFYVM_DVDPASSTHROUGH: // deprecated
    10131013            {
    1014                 ComPtr<IMediumAttachment> dvdAttachment;
    1015                 machine->GetMediumAttachment(Bstr("IDE Controller"), 1, 0, dvdAttachment.asOutParam());
    1016                 ASSERT(dvdAttachment);
    1017 
    1018                 CHECK_ERROR (dvdAttachment, COMSETTER(Passthrough)(!strcmp(ValueUnion.psz, "on")));
     1014                CHECK_ERROR (machine, PassthroughDevice(Bstr("IDE Controller"), 1, 0, !strcmp(ValueUnion.psz, "on")));
    10191015                break;
    10201016            }
  • trunk/src/VBox/Frontends/VBoxManage/VBoxManageStorageController.cpp

    r23902 r23928  
    459459            if (!RTStrICmp(pszPassThrough, "on"))
    460460            {
    461                 CHECK_ERROR (mattach, COMSETTER(Passthrough)(true));
     461                CHECK_ERROR (machine, PassthroughDevice(Bstr(pszCtl), port, device, TRUE));
    462462            }
    463463            else if (!RTStrICmp(pszPassThrough, "off"))
    464464            {
    465                 CHECK_ERROR (mattach, COMSETTER(Passthrough)(false));
     465                CHECK_ERROR (machine, PassthroughDevice(Bstr(pszCtl), port, device, FALSE));
    466466            }
    467467            else
  • trunk/src/VBox/Frontends/VirtualBox/src/VBoxVMSettingsHD.cpp

    r23854 r23928  
    17891789                QString attMediumId = mStorageModel->data (attIndex, StorageModel::R_AttMediumId).toString();
    17901790                mMachine.AttachDevice (ctrName, attStorageSlot.port, attStorageSlot.device, attDeviceType, attMediumId);
    1791                 CMediumAttachment attachment = mMachine.GetMediumAttachment (ctrName, attStorageSlot.port, attStorageSlot.device);
    1792                 attachment.SetPassthrough (mStorageModel->data (attIndex, StorageModel::R_AttIsHostDrive).toBool() &&
    1793                                            mStorageModel->data (attIndex, StorageModel::R_AttIsPassthrough).toBool());
     1791                if (attDeviceType == KDeviceType_DVD)
     1792                    mMachine.PassthroughDevice (ctrName, attStorageSlot.port, attStorageSlot.device,
     1793                                                mStorageModel->data (attIndex, StorageModel::R_AttIsPassthrough).toBool());
    17941794                maxUsedPort = attStorageSlot.port > maxUsedPort ? attStorageSlot.port : maxUsedPort;
    17951795            }
  • trunk/src/VBox/Main/MachineImpl.cpp

    r23921 r23928  
    25182518     * still refers to the original and is not valid for the copy */
    25192519    mMediaData->mAttachments.remove(pAttach);
     2520
     2521    return S_OK;
     2522}
     2523
     2524STDMETHODIMP Machine::PassthroughDevice(IN_BSTR aControllerName, LONG aControllerPort,
     2525                                        LONG aDevice, BOOL aPassthrough)
     2526{
     2527    CheckComArgNotNull(aControllerName);
     2528
     2529    LogFlowThisFunc(("aControllerName=\"%ls\" aControllerPort=%ld aDevice=%ld aPassthrough=%d\n",
     2530                     aControllerName, aControllerPort, aDevice, aPassthrough));
     2531
     2532    AutoCaller autoCaller(this);
     2533    CheckComRCReturnRC(autoCaller.rc());
     2534
     2535    AutoWriteLock alock(this);
     2536
     2537    HRESULT rc = checkStateDependency(MutableStateDep);
     2538    CheckComRCReturnRC(rc);
     2539
     2540    AssertReturn(mData->mMachineState != MachineState_Saved, E_FAIL);
     2541
     2542    if (Global::IsOnlineOrTransient(mData->mMachineState))
     2543        return setError(VBOX_E_INVALID_VM_STATE,
     2544                        tr("Invalid machine state: %s"),
     2545                        Global::stringifyMachineState(mData->mMachineState));
     2546
     2547    MediumAttachment *pAttach = findAttachment(mMediaData->mAttachments,
     2548                                               aControllerName,
     2549                                               aControllerPort,
     2550                                               aDevice);
     2551    if (!pAttach)
     2552        return setError(VBOX_E_OBJECT_NOT_FOUND,
     2553                        tr("No storage device attached to device slot %d on port %d of controller '%ls'"),
     2554                        aDevice, aControllerPort, aControllerName);
     2555
     2556
     2557    mMediaData.backup();
     2558
     2559    AutoWriteLock attLock(pAttach);
     2560
     2561    if (pAttach->type() != DeviceType_DVD)
     2562        return setError(E_INVALIDARG,
     2563                        tr("Setting passthrough rejected as the device attached to device slot %d on port %d of controller '%ls' is not a DVD"),
     2564                        aDevice, aControllerPort, aControllerName);
     2565    pAttach->updatePassthrough(aPassthrough);
    25202566
    25212567    return S_OK;
  • trunk/src/VBox/Main/MediumAttachmentImpl.cpp

    r23914 r23928  
    247247}
    248248
    249 STDMETHODIMP MediumAttachment::COMSETTER(Passthrough)(BOOL aPassthrough)
    250 {
    251     LogFlowThisFuncEnter();
    252 
    253     AutoCaller autoCaller(this);
    254     CheckComRCReturnRC(autoCaller.rc());
    255 
    256     /** @todo the entire passthrough handling can only be enabled after the
    257      *  MediumAttachment handling in Machine is fixed. */
    258 #if 0
    259     /* the machine need to be mutable */
    260     Machine::AutoMutableStateDependency adep(mParent);
    261     CheckComRCReturnRC(adep.rc());
    262 
    263     AutoWriteLock lock(this);
    264 
    265     if (m->passthrough != !!aPassthrough)
    266     {
    267         m.backup();
    268         m->passthrough = !!aPassthrough;
    269     }
    270 #endif
    271 
    272     LogFlowThisFuncLeave();
    273     return S_OK;
    274 }
    275 
    276249STDMETHODIMP MediumAttachment::COMGETTER(Passthrough)(BOOL *aPassthrough)
    277250{
  • trunk/src/VBox/Main/idl/VirtualBox.xidl

    r23897 r23928  
    40604060  <interface
    40614061     name="IMachine" extends="$unknown"
    4062      uuid="d867a463-0f78-4ec7-a876-8da001464537"
     4062     uuid="db35f17a-179f-4332-91b2-a49d5cfb678c"
    40634063     wsmap="managed"
    40644064     >
     
    47514751    </method>
    47524752
     4753    <method name="passthroughDevice">
     4754      <desc>
     4755        Sets the passthrough mode of an existing DVD device. Changing the
     4756        setting while the VM is running is forbidden. The setting is only used
     4757        if at VM start the device is configured as a host DVD drive, in all
     4758        other cases it is ignored. The device must already exist; see
     4759        <link to="IMachine::attachDevice"/> for how to attach a new device.
     4760
     4761        The @a controllerPort and @a device parameters specify the device slot and
     4762        have have the same meaning as with <link to="IMachine::attachDevice" />.
     4763
     4764        <result name="E_INVALIDARG">
     4765          SATA device, SATA port, IDE port or IDE slot out of range.
     4766        </result>
     4767        <result name="VBOX_E_INVALID_OBJECT_STATE">
     4768          Attempt to modify an unregistered virtual machine.
     4769        </result>
     4770        <result name="VBOX_E_INVALID_VM_STATE">
     4771          Invalid machine state.
     4772        </result>
     4773
     4774      </desc>
     4775      <param name="name" type="wstring" dir="in">
     4776        <desc>Name of the storage controller.</desc>
     4777      </param>
     4778      <param name="controllerPort" type="long" dir="in">
     4779        <desc>Storage controller port.</desc>
     4780      </param>
     4781      <param name="device" type="long" dir="in">
     4782        <desc>Device slot in the given port.</desc>
     4783      </param>
     4784      <param name="passthrough" type="boolean" dir="in">
     4785        <desc>New value for the passthrough setting.</desc>
     4786      </param>
     4787    </method>
     4788
    47534789    <method name="mountMedium">
    47544790      <desc>
     
    83638399  <interface
    83648400    name="IMediumAttachment" extends="$unknown"
    8365     uuid="ff554585-560a-489d-963c-cf6da6a826de"
     8401    uuid="7bb6ac41-8c03-4863-9eea-d9c76561b8d1"
    83668402    wsmap="struct"
    83678403  >
     
    84008436    </attribute>
    84018437
    8402     <attribute name="passthrough" type="boolean" readonly="no">
     8438    <attribute name="passthrough" type="boolean" readonly="yes">
    84038439      <desc>Pass I/O requests through to a device on the host.</desc>
    84048440    </attribute>
  • trunk/src/VBox/Main/include/MachineImpl.h

    r23882 r23928  
    577577                            LONG aDevice, DeviceType_T aType, IN_BSTR aId);
    578578    STDMETHOD(DetachDevice)(IN_BSTR aControllerName, LONG aControllerPort, LONG aDevice);
     579    STDMETHOD(PassthroughDevice)(IN_BSTR aControllerName, LONG aControllerPort, LONG aDevice, BOOL aPassthrough);
    579580    STDMETHOD(MountMedium)(IN_BSTR aControllerName, LONG aControllerPort,
    580581                           LONG aDevice, IN_BSTR aId);
  • trunk/src/VBox/Main/include/MediumAttachmentImpl.h

    r23914 r23928  
    7474    STDMETHOD(COMGETTER(Type))(DeviceType_T *aType);
    7575    STDMETHOD(COMGETTER(Passthrough))(BOOL *aPassthrough);
    76     STDMETHOD(COMSETTER(Passthrough))(BOOL aPassthrough);
    7776
    7877    // unsafe inline public methods for internal purposes only (ensure there is
     
    102101        m->medium = aMedium;
    103102        m->implicit = aImplicit;
     103    }
     104
     105    /** Must be called from under this object's write lock. */
     106    void updatePassthrough(bool aPassthrough)
     107    {
     108        m.backup();
     109        m->passthrough = aPassthrough;
    104110    }
    105111
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