VirtualBox

Changeset 48879 in vbox


Ignore:
Timestamp:
Oct 4, 2013 8:37:50 AM (12 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
89551
Message:

Main/MediumAttachment+Machine: stub attribute/method for an explicit hot-pluggable medium attachment flag, to be used by AHCI soon

Location:
trunk
Files:
8 edited

Legend:

Unmodified
Added
Removed
  • trunk/include/VBox/settings.h

    r48538 r48879  
    978978    // Whether the medium supports discarding unused blocks:
    979979    bool                fDiscard;
     980
     981    // Whether the medium is hot-pluggable:
     982    bool                fHotPluggable;
    980983
    981984    int32_t             lPort;
  • trunk/src/VBox/Main/idl/VirtualBox.xidl

    r48824 r48879  
    41224122  <interface
    41234123    name="IMachine" extends="$unknown"
    4124     uuid="7108c7c7-2c0a-47ee-9c69-022fe2a466bf"
     4124    uuid="480cf695-2d8d-4256-9c7c-cce4184fa048"
    41254125    wsmap="managed"
    41264126    >
     
    55645564    </method>
    55655565
     5566    <method name="setHotPluggableForDevice">
     5567      <desc>
     5568        Sets a flag in the device information which indicates that the attached
     5569        device is hot pluggable or not. This may or may not be supported by a
     5570        particular controller and/or drive, and is silently ignored in the
     5571        latter case. Changing the setting while the VM is running is forbidden.
     5572        The device must already exist; see <link to="IMachine::attachDevice"/>
     5573        for how to attach a new device.
     5574
     5575        The @a controllerPort and @a device parameters specify the device slot and
     5576        have have the same meaning as with <link to="IMachine::attachDevice" />.
     5577
     5578        <result name="E_INVALIDARG">
     5579          SATA device, SATA port, IDE port or IDE slot out of range.
     5580        </result>
     5581        <result name="VBOX_E_INVALID_OBJECT_STATE">
     5582          Attempt to modify an unregistered virtual machine.
     5583        </result>
     5584        <result name="VBOX_E_INVALID_VM_STATE">
     5585          Invalid machine state.
     5586        </result>
     5587        <result name="VBOX_E_NOT_SUPPORTED">
     5588          Controller doesn't support hot plugging.
     5589        </result>
     5590      </desc>
     5591
     5592      <param name="name" type="wstring" dir="in">
     5593        <desc>Name of the storage controller.</desc>
     5594      </param>
     5595      <param name="controllerPort" type="long" dir="in">
     5596        <desc>Storage controller port.</desc>
     5597      </param>
     5598      <param name="device" type="long" dir="in">
     5599        <desc>Device slot in the given port.</desc>
     5600      </param>
     5601      <param name="hotPluggable" type="boolean" dir="in">
     5602        <desc>New value for the hot-pluggable device flag.</desc>
     5603      </param>
     5604    </method>
     5605
    55665606    <method name="setBandwidthGroupForDevice">
    55675607      <desc>
     
    56295669
    56305670    <method name="unmountMedium">
    5631           <desc>
    5632             Unmounts any currently mounted medium (<link to="IMedium" />,
    5633             identified by the given UUID @a id) to the given storage controller
    5634             (<link to="IStorageController" />, identified by @a name),
    5635             at the indicated port and device. The device must already exist;
    5636 
    5637             This method is intended only for managing removable media, where the
    5638             device is fixed but media is changeable at runtime (such as DVDs
    5639             and floppies). It cannot be used for fixed media such as hard disks.
    5640 
    5641             The @a controllerPort and @a device parameters specify the device slot
    5642             and have have the same meaning as with
    5643             <link to="IMachine::attachDevice" />.
    5644 
    5645             The specified device slot must have a medium mounted, which will be
    5646             unmounted. If there is no mounted medium it will do nothing.
    5647             See <link to="IMedium"/> for more detailed information about
    5648             attaching/unmounting media.
    5649 
    5650             <result name="E_INVALIDARG">
    5651             SATA device, SATA port, IDE port or IDE slot out of range.
    5652             </result>
    5653             <result name="VBOX_E_INVALID_OBJECT_STATE">
    5654             Attempt to unmount medium that is not removable - not DVD or floppy.
    5655             </result>
    5656             <result name="VBOX_E_INVALID_VM_STATE">
    5657             Invalid machine state.
    5658             </result>
    5659             <result name="VBOX_E_OBJECT_IN_USE">
    5660             Medium already attached to this or another virtual machine.
    5661             </result>
    5662             <result name="VBOX_E_OBJECT_NOT_FOUND">
    5663             Medium not attached to specified port, device, controller.
    5664             </result>
    5665 
    5666             </desc>
    5667               <param name="name" type="wstring" dir="in">
    5668               <desc>Name of the storage controller to unmount the medium from.</desc>
    5669               </param>
    5670               <param name="controllerPort" type="long" dir="in">
    5671               <desc>Port to unmount the medium from.</desc>
    5672               </param>
    5673               <param name="device" type="long" dir="in">
    5674               <desc>Device slot in the given port to unmount the medium from.</desc>
    5675               </param>
    5676               <param name="force" type="boolean" dir="in">
    5677               <desc>Allows to force unmount of a medium which is locked by
    5678               the device slot in the given port medium is attached to.</desc>
    5679               </param>
    5680           </method>
     5671      <desc>
     5672        Unmounts any currently mounted medium (<link to="IMedium" />,
     5673        identified by the given UUID @a id) to the given storage controller
     5674        (<link to="IStorageController" />, identified by @a name),
     5675        at the indicated port and device. The device must already exist;
     5676
     5677        This method is intended only for managing removable media, where the
     5678        device is fixed but media is changeable at runtime (such as DVDs
     5679        and floppies). It cannot be used for fixed media such as hard disks.
     5680
     5681        The @a controllerPort and @a device parameters specify the device slot
     5682        and have have the same meaning as with
     5683        <link to="IMachine::attachDevice" />.
     5684
     5685        The specified device slot must have a medium mounted, which will be
     5686        unmounted. If there is no mounted medium it will do nothing.
     5687        See <link to="IMedium"/> for more detailed information about
     5688        attaching/unmounting media.
     5689
     5690        <result name="E_INVALIDARG">
     5691          SATA device, SATA port, IDE port or IDE slot out of range.
     5692        </result>
     5693        <result name="VBOX_E_INVALID_OBJECT_STATE">
     5694          Attempt to unmount medium that is not removable - not DVD or floppy.
     5695        </result>
     5696        <result name="VBOX_E_INVALID_VM_STATE">
     5697          Invalid machine state.
     5698        </result>
     5699        <result name="VBOX_E_OBJECT_IN_USE">
     5700          Medium already attached to this or another virtual machine.
     5701        </result>
     5702        <result name="VBOX_E_OBJECT_NOT_FOUND">
     5703          Medium not attached to specified port, device, controller.
     5704        </result>
     5705      </desc>
     5706
     5707      <param name="name" type="wstring" dir="in">
     5708        <desc>Name of the storage controller to unmount the medium from.</desc>
     5709      </param>
     5710      <param name="controllerPort" type="long" dir="in">
     5711        <desc>Port to unmount the medium from.</desc>
     5712      </param>
     5713      <param name="device" type="long" dir="in">
     5714        <desc>Device slot in the given port to unmount the medium from.</desc>
     5715      </param>
     5716      <param name="force" type="boolean" dir="in">
     5717        <desc>Allows to force unmount of a medium which is locked by
     5718        the device slot in the given port medium is attached to.</desc>
     5719      </param>
     5720    </method>
    56815721
    56825722    <method name="mountMedium">
     
    1285412894  <interface
    1285512895    name="IMediumAttachment" extends="$unknown"
    12856     uuid="5ee464d6-0613-4331-b154-7ce12170ef9f"
     12896    uuid="4b252567-5d4e-4db8-b3c8-569ec1c9236c"
    1285712897    wsmap="struct"
    1285812898    >
     
    1308213122    <attribute name="discard" type="boolean" readonly="yes">
    1308313123      <desc>Whether the associated medium supports discarding unused blocks.</desc>
     13124    </attribute>
     13125
     13126    <attribute name="hotPluggable" type="boolean" readonly="yes">
     13127      <desc>Whether this attachment is hot pluggable or not.</desc>
    1308413128    </attribute>
    1308513129
  • trunk/src/VBox/Main/include/MachineImpl.h

    r48538 r48879  
    543543    STDMETHOD(NonRotationalDevice)(IN_BSTR aControllerName, LONG aControllerPort, LONG aDevice, BOOL aNonRotational);
    544544    STDMETHOD(SetAutoDiscardForDevice)(IN_BSTR aControllerName, LONG aControllerPort, LONG aDevice, BOOL aDiscard);
     545    STDMETHOD(SetHotPluggableForDevice)(IN_BSTR aControllerName, LONG aControllerPort, LONG aDevice, BOOL aHotPluggable);
    545546    STDMETHOD(SetNoBandwidthGroupForDevice)(IN_BSTR aControllerName, LONG aControllerPort,
    546547                                            LONG aDevice);
  • trunk/src/VBox/Main/include/MediumAttachmentImpl.h

    r38873 r48879  
    55
    66/*
    7  * Copyright (C) 2006-2011 Oracle Corporation
     7 * Copyright (C) 2006-2013 Oracle Corporation
    88 *
    99 * This file is part of VirtualBox Open Source Edition (OSE), as
     
    5252                 bool fNonRotational,
    5353                 bool fDiscard,
     54                 bool fHotPluggable,
    5455                 const Utf8Str &strBandwidthGroup);
    5556    HRESULT initCopy(Machine *aParent, MediumAttachment *aThat);
     
    7172    STDMETHOD(COMGETTER(Discard))(BOOL *aDiscard);
    7273    STDMETHOD(COMGETTER(BandwidthGroup))(IBandwidthGroup **aBwGroup);
     74    STDMETHOD(COMGETTER(HotPluggable))(BOOL *aHotPluggable);
    7375
    7476    // public internal methods
     
    9193    bool getDiscard() const;
    9294    const Utf8Str& getBandwidthGroup() const;
     95    bool getHotPluggable() const;
    9396
    9497    bool matches(CBSTR aControllerName, LONG aPort, LONG aDevice);
     
    117120    void updateParentMachine(Machine * const pMachine);
    118121
     122    /** Must be called from under this object's write lock. */
     123    void updateHotPluggable(bool aHotPluggable);
     124
    119125    /** Get a unique and somewhat descriptive name for logging. */
    120126    const char* getLogName(void) const { return mLogName.c_str(); }
  • trunk/src/VBox/Main/src-server/MachineImpl.cpp

    r48735 r48879  
    45014501                          false /* fNonRotational */,
    45024502                          false /* fDiscard */,
     4503                          false /* fHotPluggable */,
    45034504                          Utf8Str::Empty);
    45044505    if (FAILED(rc)) return rc;
     
    48284829                        aDevice, aControllerPort, aControllerName);
    48294830    pAttach->updateDiscard(!!aDiscard);
     4831
     4832    return S_OK;
     4833}
     4834
     4835STDMETHODIMP Machine::SetHotPluggableForDevice(IN_BSTR aControllerName, LONG aControllerPort,
     4836                                               LONG aDevice, BOOL aHotPluggable)
     4837{
     4838    CheckComArgStrNotEmptyOrNull(aControllerName);
     4839
     4840    LogFlowThisFunc(("aControllerName=\"%ls\" aControllerPort=%d aDevice=%d aHotPluggable=%d\n",
     4841                     aControllerName, aControllerPort, aDevice, aHotPluggable));
     4842
     4843    AutoCaller autoCaller(this);
     4844    if (FAILED(autoCaller.rc())) return autoCaller.rc();
     4845
     4846    AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS);
     4847
     4848    HRESULT rc = checkStateDependency(MutableStateDep);
     4849    if (FAILED(rc)) return rc;
     4850
     4851    AssertReturn(mData->mMachineState != MachineState_Saved, E_FAIL);
     4852
     4853    if (Global::IsOnlineOrTransient(mData->mMachineState))
     4854        return setError(VBOX_E_INVALID_VM_STATE,
     4855                        tr("Invalid machine state: %s"),
     4856                        Global::stringifyMachineState(mData->mMachineState));
     4857
     4858    MediumAttachment *pAttach = findAttachment(mMediaData->mAttachments,
     4859                                               aControllerName,
     4860                                               aControllerPort,
     4861                                               aDevice);
     4862    if (!pAttach)
     4863        return setError(VBOX_E_OBJECT_NOT_FOUND,
     4864                        tr("No storage device attached to device slot %d on port %d of controller '%ls'"),
     4865                        aDevice, aControllerPort, aControllerName);
     4866
     4867    /** @todo remove this blocker and add the missing code to support this
     4868     * flag properly in all code areas, with proper support checks below. */
     4869    return setError(VBOX_E_NOT_SUPPORTED,
     4870                    tr("Controller '%ls' does not support changing the hot-pluggable device flag"),
     4871                    aControllerName);
     4872
     4873    setModified(IsModified_Storage);
     4874    mMediaData.backup();
     4875
     4876    AutoWriteLock attLock(pAttach COMMA_LOCKVAL_SRC_POS);
     4877
     4878    if (pAttach->getType() == DeviceType_Floppy)
     4879        return setError(E_INVALIDARG,
     4880                        tr("Setting the hot-pluggable device flag rejected as the device attached to device slot %d on port %d of controller '%ls' is a floppy drive"),
     4881                        aDevice, aControllerPort, aControllerName);
     4882    pAttach->updateHotPluggable(!!aHotPluggable);
    48304883
    48314884    return S_OK;
     
    97169769                               dev.fNonRotational,
    97179770                               dev.fDiscard,
     9771        /// @todo load setting once the hot-pluggable flag works
     9772                               false /*dev.fHotPluggable*/,
    97189773                               pBwGroup.isNull() ? Utf8Str::Empty : pBwGroup->getName());
    97199774        if (FAILED(rc)) break;
     
    1081910874        dev.lDevice = pAttach->getDevice();
    1082010875        dev.fPassThrough = pAttach->getPassthrough();
     10876        /// @todo save setting once the hot-pluggable flag works
     10877        dev.fHotPluggable = false /* pAttach->getHotPluggable()*/;
    1082110878        if (pMedium)
    1082210879        {
     
    1116111218                                  pAtt->getNonRotational(),
    1116211219                                  pAtt->getDiscard(),
     11220                                  pAtt->getHotPluggable(),
    1116311221                                  pAtt->getBandwidthGroup());
    1116411222            if (FAILED(rc)) throw rc;
     
    1277712835        {
    1277812836            Bstr name;
    12779            
     12837
    1278012838            hrc = mNetworkAdapters[slot]->COMGETTER(NATNetwork)(name.asOutParam());
    1278112839            if (SUCCEEDED(hrc))
  • trunk/src/VBox/Main/src-server/MediumAttachmentImpl.cpp

    r38873 r48879  
    55
    66/*
    7  * Copyright (C) 2006-2011 Oracle Corporation
     7 * Copyright (C) 2006-2013 Oracle Corporation
    88 *
    99 * This file is part of VirtualBox Open Source Edition (OSE), as
     
    4343          fNonRotational(false),
    4444          fDiscard(false),
    45           fImplicit(false)
     45          fImplicit(false),
     46          fHotPluggable(false)
    4647    { }
    4748
     
    6364    bool                fDiscard;
    6465    bool                fImplicit;
     66    bool                fHotPluggable;
    6567};
    6668
     
    123125                               bool aNonRotational,
    124126                               bool aDiscard,
     127                               bool aHotPluggable,
    125128                               const Utf8Str &strBandwidthGroup)
    126129{
    127130    LogFlowThisFuncEnter();
    128     LogFlowThisFunc(("aParent=%p aMedium=%p aControllerName=%ls aPort=%d aDevice=%d aType=%d aImplicit=%d aPassthrough=%d aTempEject=%d aNonRotational=%d strBandwithGroup=%s\n", aParent, aMedium, aControllerName.raw(), aPort, aDevice, aType, aImplicit, aPassthrough, aTempEject, aNonRotational, strBandwidthGroup.c_str()));
     131    LogFlowThisFunc(("aParent=%p aMedium=%p aControllerName=%ls aPort=%d aDevice=%d aType=%d aImplicit=%d aPassthrough=%d aTempEject=%d aNonRotational=%d aDiscard=%d aHotPluggable=%d strBandwithGroup=%s\n", aParent, aMedium, aControllerName.raw(), aPort, aDevice, aType, aImplicit, aPassthrough, aTempEject, aNonRotational, aDiscard, aHotPluggable, strBandwidthGroup.c_str()));
    129132
    130133    if (aType == DeviceType_HardDisk)
     
    152155    m->bd->fDiscard = aDiscard;
    153156    m->bd->fImplicit = aImplicit;
     157    m->bd->fHotPluggable = aHotPluggable;
    154158
    155159    /* Confirm a successful initialization when it's the case */
     
    417421}
    418422
     423STDMETHODIMP MediumAttachment::COMGETTER(HotPluggable)(BOOL *aHotPluggable)
     424{
     425    LogFlowThisFuncEnter();
     426
     427    CheckComArgOutPointerValid(aHotPluggable);
     428
     429    AutoCaller autoCaller(this);
     430    if (FAILED(autoCaller.rc())) return autoCaller.rc();
     431
     432    AutoReadLock lock(this COMMA_LOCKVAL_SRC_POS);
     433
     434    *aHotPluggable = m->bd->fHotPluggable;
     435
     436    LogFlowThisFuncLeave();
     437    return S_OK;
     438}
     439
    419440/**
    420441 *  @note Locks this object for writing.
     
    511532    AutoReadLock lock(this COMMA_LOCKVAL_SRC_POS);
    512533    return m->bd->fDiscard;
     534}
     535
     536bool MediumAttachment::getHotPluggable() const
     537{
     538    AutoReadLock lock(this COMMA_LOCKVAL_SRC_POS);
     539    return m->bd->fHotPluggable;
    513540}
    514541
  • trunk/src/VBox/Main/xml/Settings.cpp

    r48538 r48879  
    20222022                  && (fNonRotational            == a.fNonRotational)
    20232023                  && (fDiscard                  == a.fDiscard)
     2024                  && (fHotPluggable             == a.fHotPluggable)
    20242025                  && (lPort                     == a.lPort)
    20252026                  && (lDevice                   == a.lDevice)
     
    34893490                    throw ConfigFileError(this, pelmImage, N_("Required AttachedDevice/@device attribute is missing"));
    34903491
     3492                pelmAttached->getAttributeValue("hotpluggable", att.fHotPluggable);
    34913493                pelmAttached->getAttributeValue("bandwidthGroup", att.strBwGroup);
    34923494                sctl.llAttachedDevices.push_back(att);
     
    49184920            pelmDevice->setAttribute("type", pcszType);
    49194921
     4922            if (att.fHotPluggable)
     4923                pelmDevice->setAttribute("hotpluggable", att.fHotPluggable);
     4924
    49204925            pelmDevice->setAttribute("port", att.lPort);
    49214926            pelmDevice->setAttribute("device", att.lDevice);
  • trunk/src/VBox/Main/xml/VirtualBox-settings.xsd

    r44948 r48879  
    626626  <xsd:attribute name="nonrotational" type="xsd:boolean" default="false"/>
    627627  <xsd:attribute name="discard" type="xsd:boolean" default="false"/>
     628  <xsd:attribute name="hotpluggable" type="xsd:boolean" default="false"/>
    628629</xsd:complexType>
    629630
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