VirtualBox

Changeset 15178 in vbox


Ignore:
Timestamp:
Dec 9, 2008 2:40:31 PM (16 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
40588
Message:

#3285: Improve error handling API to include unique error numbers
Document

  • IMedium::getSnapshotIds
  • IMedium::lockRead
  • IMedium::unlockRead
  • IMedium::lockWrite
  • IMedium::unlockWrite
  • IMedium::close
Location:
trunk/src/VBox/Main
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Main/MediumImpl.cpp

    r15124 r15178  
    238238                                         ComSafeGUIDArrayOut (aSnapshotIds))
    239239{
    240     if (Guid (aMachineId).isEmpty())
    241         return E_INVALIDARG;
    242     if (ComSafeGUIDArrayOutIsNull (aSnapshotIds))
    243         return E_POINTER;
     240    CheckComArgExpr(aMachineId, Guid (aMachineId).isEmpty() == false);
     241    CheckComArgSafeArrayNotNull(aSnapshotIds);
    244242
    245243    AutoCaller autoCaller (this);
     
    372370        default:
    373371        {
    374             rc = setError (E_FAIL,
     372            rc = setError (VBOX_E_INVALID_OBJECT_STATE,
    375373                tr ("Medium '%ls' is not locked for reading"),
    376374                m.locationFull.raw());
     
    451449        default:
    452450        {
    453             rc = setError (E_FAIL,
     451            rc = setError (VBOX_E_INVALID_OBJECT_STATE,
    454452                tr ("Medium '%ls' is not locked for writing"),
    455453                m.locationFull.raw());
     
    497495
    498496    if (m.backRefs.size() != 0)
    499         return setError (E_FAIL,
     497        return setError (VBOX_E_OBJECT_IN_USE,
    500498            tr ("Medium '%ls' is attached to %d virtual machines"),
    501499                m.locationFull.raw(), m.backRefs.size());
     
    855853        case MediaState_NotCreated:
    856854        {
    857             rc = setError (E_FAIL,
     855            rc = setError (VBOX_E_INVALID_OBJECT_STATE,
    858856                tr ("Storage for the medium '%ls' is not created"),
    859857                m.locationFull.raw());
     
    862860        case MediaState_Created:
    863861        {
    864             rc = setError (E_FAIL,
     862            rc = setError (VBOX_E_INVALID_OBJECT_STATE,
    865863                tr ("Storage for the medium '%ls' is already created"),
    866864                m.locationFull.raw());
     
    869867        case MediaState_LockedRead:
    870868        {
    871             rc = setError (E_FAIL,
     869            rc = setError (VBOX_E_INVALID_OBJECT_STATE,
    872870                tr ("Medium '%ls' is locked for reading by another task"),
    873871                m.locationFull.raw());
     
    876874        case MediaState_LockedWrite:
    877875        {
    878             rc = setError (E_FAIL,
     876            rc = setError (VBOX_E_INVALID_OBJECT_STATE,
    879877                tr ("Medium '%ls' is locked for writing by another task"),
    880878                m.locationFull.raw());
     
    885883            /* be in sync with Console::powerUpThread() */
    886884            if (!m.lastAccessError.isEmpty())
    887                 rc = setError (E_FAIL,
     885                rc = setError (VBOX_E_INVALID_OBJECT_STATE,
    888886                    tr ("Medium '%ls' is not accessible. %ls"),
    889887                    m.locationFull.raw(), m.lastAccessError.raw());
    890888            else
    891                 rc = setError (E_FAIL,
     889                rc = setError (VBOX_E_INVALID_OBJECT_STATE,
    892890                    tr ("Medium '%ls' is not accessible"),
    893891                    m.locationFull.raw());
     
    896894        case MediaState_Creating:
    897895        {
    898             rc = setError (E_FAIL,
     896            rc = setError (VBOX_E_INVALID_OBJECT_STATE,
    899897                tr ("Storage for the medium '%ls' is being created"),
    900898                m.locationFull.raw(), m.lastAccessError.raw());
     
    903901        case MediaState_Deleting:
    904902        {
    905             rc = setError (E_FAIL,
     903            rc = setError (VBOX_E_INVALID_OBJECT_STATE,
    906904                tr ("Storage for the medium '%ls' is being deleted"),
    907905                m.locationFull.raw(), m.lastAccessError.raw());
  • trunk/src/VBox/Main/idl/VirtualBox.xidl

    r15165 r15178  
    72727272        <link to="#lockWrite()"/>) in which case an error is returned.
    72737273
    7274         When the medium is locked for reading, it cannot be modified from within
    7275         VirtualBox. This means that any method that changes the properties of
    7276         this medium or contents of the storage unit will return an error (unless
    7277         explicitly stated otherwise) and that an attempt to start a virtual
    7278         machine that wants to modify the medium will also fail.
    7279 
    7280         When the virtual machine is started up, it locks for reading all media
    7281         it uses in read-only mode. If some media cannot be locked for reading,
    7282         the startup procedure will fail.
    7283 
    7284         The medium locked for reading must be unlocked using the
    7285         <link to="#unlockRead()"/> method. Calls to <link to="#lockRead()"/> can
    7286         be nested and must be followed by the same number of paired
     7274        When the medium is locked for reading, it cannot be modified
     7275        from within VirtualBox. This means that any method that changes
     7276        the properties of this medium or contents of the storage unit
     7277        will return an error (unless explicitly stated otherwise) and
     7278        that an attempt to start a virtual machine that wants to modify
     7279        the medium will also fail.
     7280
     7281        When the virtual machine is started up, it locks for reading all
     7282        media it uses in read-only mode. If some media cannot be locked
     7283        for reading, the startup procedure will fail.
     7284
     7285        The medium locked for reading must be unlocked using the <link
     7286        to="#unlockRead()"/> method. Calls to <link to="#lockRead()"/>
     7287        can be nested and must be followed by the same number of paired
    72877288        <link to="#unlockRead()"/> calls.
    72887289
    7289         This method sets the media state to <link to="MediaState::LockedRead"/>
    7290         on success. The state prior to this call must be
    7291         <link to="MediaState::Created"/>,
    7292         <link to="MediaState::Inaccessible"/> or
    7293         <link to="MediaState::LockedRead"/>. As you can see, inaccessible media
    7294         can be locked too. This is not an error; this method performs a logical
    7295         lock that prevents modifications of this media through the VirtualBox
    7296         API, not a physical lock of the underlying storage unit.
    7297 
    7298         Either on success or on failure, this method returns the current state
    7299         of the medium <b>before</b> the operation.
     7290        This method sets the media state to <link
     7291        to="MediaState::LockedRead"/> on success. The state prior to
     7292        this call must be <link to="MediaState::Created"/>, <link
     7293        to="MediaState::Inaccessible"/> or <link
     7294        to="MediaState::LockedRead"/>. As you can see, inaccessible
     7295        media can be locked too. This is not an error; this method
     7296        performs a logical lock that prevents modifications of this
     7297        media through the VirtualBox API, not a physical lock of the
     7298        underlying storage unit.
     7299
     7300        This method returns the current state of the medium
     7301        <b>before</b> the operation.
     7302
     7303        <result name="VBOX_E_INVALID_OBJECT_STATE">
     7304          Invalid media state (e.g. not created, locked, inaccessible,
     7305          creating, deleting).
     7306        </result>
     7307
    73007308      </desc>
    73017309      <param name="state" type="MediaState" dir="return">
     
    73147322
    73157323        See <link to="#lockRead()"/> for more details.
     7324
     7325        <result name="VBOX_E_INVALID_OBJECT_STATE">
     7326          Medium not locked for reading.
     7327        </result>
     7328
    73167329      </desc>
    73177330      <param name="state" type="MediaState" dir="return">
     
    73267339        Locks this medium for writing.
    73277340
    7328         The write lock, as opposed to <link to="#lockRead()"/>, is exclusive:
    7329         there may be only one client that holds a write lock and there may be no
    7330         read locks while the write lock is held.
    7331 
    7332         When the medium is locked for writing, it cannot be modified from within
    7333         VirtualBox and it is not guaranteed that the values of its properties
    7334         are up-to-date. Any method that changes the properties of this medium or
    7335         contents of the storage unit will return an error ((unless explicitly
    7336         stated otherwise) and an attempt to start a virtual machine that wants
    7337         to modify or to read the medium will also fail.
    7338 
    7339         When the virtual machine is started up, it locks for writing all media
    7340         it uses to write data to. If some media cannot be locked for writing,
    7341         the startup procedure will fail.
    7342 
    7343         The medium locked for writing must be unlocked using the
    7344         <link to="#unlockWrite()"/> method. Calls to <link to="#lockWrite()"/>
    7345         can <b>not</b> be nested and must be followed by a paired
    7346         <link to="#unlockWrite()"/> call.
    7347 
    7348         This method sets the media state to <link to="MediaState::LockedWrite"/>
    7349         on success. The state prior to this call must be
    7350         <link to="MediaState::Created"/> or
    7351         <link to="MediaState::Inaccessible"/>. As you can see, inaccessible media
    7352         can be locked too. This is not an error; this method performs a logical
    7353         lock that prevents modifications of this media through the VirtualBox
    7354         API, not a physical lock of the underlying storage unit.
    7355 
    7356         Either on success or on failure, this method returns the current state
    7357         of the medium <b>before</b> the operation.
     7341        The write lock, as opposed to <link to="#lockRead()"/>, is
     7342        exclusive: there may be only one client that holds a write lock
     7343        and there may be no read locks while the write lock is held.
     7344
     7345        When the medium is locked for writing, it cannot be modified
     7346        from within VirtualBox and it is not guaranteed that the values
     7347        of its properties are up-to-date. Any method that changes the
     7348        properties of this medium or contents of the storage unit will
     7349        return an error ((unless explicitly stated otherwise) and an
     7350        attempt to start a virtual machine that wants to modify or to
     7351        read the medium will also fail.
     7352
     7353        When the virtual machine is started up, it locks for writing all
     7354        media it uses to write data to. If some media cannot be locked
     7355        for writing, the startup procedure will fail.
     7356
     7357        The medium locked for writing must be unlocked using the <link
     7358        to="#unlockWrite()"/> method. Calls to <link to="#lockWrite()"/>
     7359        can <b>not</b> be nested and must be followed by a paired <link
     7360        to="#unlockWrite()"/> call.
     7361
     7362        This method sets the media state to <link
     7363        to="MediaState::LockedWrite"/> on success. The state prior to
     7364        this call must be <link to="MediaState::Created"/> or <link
     7365        to="MediaState::Inaccessible"/>. As you can see, inaccessible
     7366        media can be locked too. This is not an error; this method
     7367        performs a logical lock that prevents modifications of this
     7368        media through the VirtualBox API, not a physical lock of the
     7369        underlying storage unit.
     7370
     7371        Either on success or on failure, this method returns the current
     7372        state of the medium <b>before</b> the operation.
     7373
     7374        <result name="VBOX_E_INVALID_OBJECT_STATE">
     7375          Invalid media state (e.g. not created, locked, inaccessible,
     7376          creating, deleting).
     7377        </result>
     7378
    73587379      </desc>
    73597380      <param name="state" type="MediaState" dir="return">
     
    73687389        Cancels the write lock previously set by <link to="#lockWrite()"/>.
    73697390
    7370         Either on success or on failure, this method returns the current state
    7371         of the medium <b>after</b> the operation.
     7391        Either on success or on failure, this method returns the current
     7392        state of the medium <b>after</b> the operation.
    73727393
    73737394        See <link to="#lockWrite()"/> for more details.
     7395
     7396        <result name="VBOX_E_INVALID_OBJECT_STATE">
     7397          Medium not locked for writing.
     7398        </result>
     7399
    73747400      </desc>
    73757401      <param name="state" type="MediaState" dir="return">
     
    73827408    <method name="close">
    73837409      <desc>
    7384         Closes this media.
    7385 
    7386         The hard disk must not be attached to any known virtual machine and must
    7387         not have any known child hard disks, otherwise the operation will fail.
    7388 
    7389         When the hard disk is successfully closed, it gets removed from the list
    7390         of remembered hard disks, but its storage unit is not deleted. In
    7391         particular, this means that this hard disk can be later opened again
    7392         using the <link to="IVirtualBox::openHardDisk2"/> call.
    7393 
    7394         Note that after this method successfully returns, the given hard disk
    7395         object becomes uninitialized. This means that any attempt to call any of
    7396         its methods or attributes will fail with the <tt>"Object not ready"
    7397         (E_ACCESSDENIED)</tt> error.
     7410        Closes this medium.
     7411
     7412        The hard disk must not be attached to any known virtual machine
     7413        and must not have any known child hard disks, otherwise the
     7414        operation will fail.
     7415
     7416        When the hard disk is successfully closed, it gets removed from
     7417        the list of remembered hard disks, but its storage unit is not
     7418        deleted. In particular, this means that this hard disk can be
     7419        later opened again using the <link
     7420        to="IVirtualBox::openHardDisk2"/> call.
     7421
     7422        Note that after this method successfully returns, the given hard
     7423        disk object becomes uninitialized. This means that any attempt
     7424        to call any of its methods or attributes will fail with the
     7425        <tt>"Object not ready" (E_ACCESSDENIED)</tt> error.
     7426
     7427        <result name="VBOX_E_INVALID_OBJECT_STATE">
     7428          Invalid media state (other than not created, created or
     7429          inaccessible).
     7430        </result>
     7431        <result name="VBOX_E_OBJECT_IN_USE">
     7432          Medium attached to virtual machine.
     7433        </result>
     7434        <result name="VBOX_E_FILE_ERROR">
     7435          Settings file not accessible.
     7436        </result>
     7437        <result name="VBOX_E_XML_ERROR">
     7438          Could not parse the settings file.
     7439        </result>
     7440
    73987441      </desc>
    73997442    </method>
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