VirtualBox

Changeset 61713 in vbox for trunk/src/VBox/Main


Ignore:
Timestamp:
Jun 15, 2016 1:15:10 PM (9 years ago)
Author:
vboxsync
Message:

Main/MediumAttachment: Update the medium attachment log tag string whenever necessary and add some paranoia checks to catch if someone tries to change attachment settings of a snapshot.

Location:
trunk/src/VBox/Main
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Main/include/MediumAttachmentImpl.h

    r56820 r61713  
    66
    77/*
    8  * Copyright (C) 2006-2015 Oracle Corporation
     8 * Copyright (C) 2006-2016 Oracle Corporation
    99 *
    1010 * This file is part of VirtualBox Open Source Edition (OSE), as
     
    101101    void i_updateHotPluggable(bool aHotPluggable);
    102102
     103    /** Construct a unique and somewhat descriptive name for logging. */
     104    void i_updateLogName(void);
     105
    103106    /** Get a unique and somewhat descriptive name for logging. */
    104     const char* i_getLogName(void) const { return mLogName.c_str(); }
     107    const char *i_getLogName(void) const { return mLogName.c_str(); }
    105108
    106109private:
  • trunk/src/VBox/Main/src-server/MediumAttachmentImpl.cpp

    r61380 r61713  
    130130    m->bd->mData.strBwGroup = strBandwidthGroup;
    131131    unconst(m->bd->strControllerName) = aControllerName;
    132     m->bd->mData.lPort   = aPort;
     132    m->bd->mData.lPort = aPort;
    133133    m->bd->mData.lDevice = aDevice;
    134     m->bd->mData.deviceType    = aType;
     134    m->bd->mData.deviceType = aType;
    135135
    136136    m->bd->mData.fPassThrough = aPassthrough;
     
    145145
    146146    /* Construct a short log name for this attachment. */
    147     Utf8Str ctlName(aControllerName);
    148     const char *psz = strpbrk(ctlName.c_str(), " \t:-");
    149     mLogName = Utf8StrFmt("MA%p[%.*s:%u:%u:%s%s]",
    150                           this,
    151                           psz ? psz - ctlName.c_str() : 4, ctlName.c_str(),
    152                           aPort, aDevice, Global::stringifyDeviceType(aType),
    153                           m->bd->fImplicit ? ":I" : "");
     147    i_updateLogName();
    154148
    155149    LogFlowThisFunc(("LEAVE - %s\n", i_getLogName()));
     
    167161
    168162    ComAssertRet(aParent && aThat, E_INVALIDARG);
     163    Assert(!aParent->i_isSnapshotMachine());
    169164
    170165    /* Enclose the state transition NotReady->InInit->Ready */
     
    184179    autoInitSpan.setSucceeded();
    185180
     181    /* Construct a short log name for this attachment. */
     182    i_updateLogName();
     183
     184    LogFlowThisFunc(("LEAVE - %s\n", i_getLogName()));
    186185    return S_OK;
    187186}
     
    399398    /* sanity */
    400399    AutoCaller autoCaller(this);
    401     AssertComRCReturnVoid (autoCaller.rc());
     400    AssertComRCReturnVoid(autoCaller.rc());
    402401
    403402    AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS);
     
    416415void MediumAttachment::i_setImplicit(bool aImplicit)
    417416{
     417    Assert(!m->pMachine->i_isSnapshotMachine());
    418418    m->bd->fImplicit = aImplicit;
     419
     420    /* Construct a short log name for this attachment. */
     421    i_updateLogName();
    419422}
    420423
     
    490493{
    491494    Assert(isWriteLockOnCurrentThread());
     495    Assert(!m->pMachine->i_isSnapshotMachine());
    492496
    493497    m->bd.backup();
    494498    unconst(m->bd->strControllerName) = aName;
     499
     500    /* Construct a short log name for this attachment. */
     501    i_updateLogName();
    495502}
    496503
     
    502509{
    503510    Assert(isWriteLockOnCurrentThread());
     511    Assert(!m->pMachine->i_isSnapshotMachine());
    504512
    505513    m->bd.backup();
     
    513521{
    514522    Assert(isWriteLockOnCurrentThread());
     523    Assert(!m->pMachine->i_isSnapshotMachine());
    515524
    516525    m->bd.backup();
     
    522531{
    523532    Assert(isWriteLockOnCurrentThread());
     533    Assert(!m->pMachine->i_isSnapshotMachine());
    524534
    525535    m->bd.backup();
     
    531541{
    532542    Assert(isWriteLockOnCurrentThread());
     543    Assert(!m->pMachine->i_isSnapshotMachine());
    533544
    534545    m->fIsEjected = true;
     
    539550{
    540551    Assert(isWriteLockOnCurrentThread());
     552    Assert(!m->pMachine->i_isSnapshotMachine());
    541553
    542554    m->bd.backup();
     
    548560{
    549561    Assert(isWriteLockOnCurrentThread());
     562    Assert(!m->pMachine->i_isSnapshotMachine());
    550563
    551564    m->bd.backup();
     
    557570{
    558571    Assert(isWriteLockOnCurrentThread());
     572    Assert(!m->pMachine->i_isSnapshotMachine());
    559573
    560574    m->bd.backup();
     
    566580    LogFlowThisFuncEnter();
    567581    Assert(isWriteLockOnCurrentThread());
     582    Assert(!m->pMachine->i_isSnapshotMachine());
    568583
    569584    m->bd.backup();
     
    578593    /* sanity */
    579594    AutoCaller autoCaller(this);
    580     AssertComRCReturnVoid (autoCaller.rc());
     595    AssertComRCReturnVoid(autoCaller.rc());
     596    Assert(!m->pMachine->i_isSnapshotMachine());
    581597
    582598    AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS);
     
    587603}
    588604
     605void MediumAttachment::i_updateLogName()
     606{
     607    const char *pszName = m->bd->strControllerName.c_str();
     608    const char *pszEndNick = strpbrk(pszName, " \t:-");
     609    mLogName = Utf8StrFmt("MA%p[%.*s:%u:%u:%s%s]",
     610                          this,
     611                          pszEndNick ? pszEndNick - pszName : 4, pszName,
     612                          m->bd->mData.lPort, m->bd->mData.lDevice, Global::stringifyDeviceType(m->bd->mData.deviceType),
     613                          m->bd->fImplicit ? ":I" : "");
     614}
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