VirtualBox

Changeset 48538 in vbox for trunk/src/VBox/Main/src-server


Ignore:
Timestamp:
Sep 19, 2013 3:17:43 PM (11 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
89083
Message:

Main/NetworkAdapter+Machine+Appliance+SystemProperties+Medium+Console+Settings+IDL: make NAT networking a separate network attachment type which improves the user experience, store the necessary settings, plus changing the design of the methods which will move images and entire VMs, they lacked a progress object
Frontends/VirtualBox: adapted fully, can configure NAT networks with proper drop down list support
Frontends/VBoxManage: also supports NAT networks completely, and adds the long missing code to list intnets

Location:
trunk/src/VBox/Main/src-server
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Main/src-server/ApplianceImpl.cpp

    r47716 r48538  
    66
    77/*
    8  * Copyright (C) 2008-2012 Oracle Corporation
     8 * Copyright (C) 2008-2013 Oracle Corporation
    99 *
    1010 * This file is part of VirtualBox Open Source Edition (OSE), as
     
    305305        case NetworkAttachmentType_HostOnly: strType = "HostOnly"; break;
    306306        case NetworkAttachmentType_Generic: strType = "Generic"; break;
     307        case NetworkAttachmentType_NATNetwork: strType = "NATNetwork"; break;
    307308        case NetworkAttachmentType_Null: strType = "Null"; break;
    308309    }
     
    775776    /** @todo: Maybe too cost-intensive; try to find a lighter way */
    776777    while (    RTPathExists(tmpName)
    777             || mVirtualBox->OpenMedium(Bstr(tmpName).raw(), DeviceType_HardDisk, AccessMode_ReadWrite, FALSE /* fForceNewUuid */,  &harddisk) != VBOX_E_OBJECT_NOT_FOUND 
     778            || mVirtualBox->OpenMedium(Bstr(tmpName).raw(), DeviceType_HardDisk, AccessMode_ReadWrite, FALSE /* fForceNewUuid */,  &harddisk) != VBOX_E_OBJECT_NOT_FOUND
    778779          )
    779780    {
  • trunk/src/VBox/Main/src-server/ApplianceImplImport.cpp

    r48117 r48538  
    27142714                        if (FAILED(rc)) throw rc;
    27152715                        /* Set the interface name to attach to */
    2716                         pNetworkAdapter->COMSETTER(BridgedInterface)(name.raw());
     2716                        rc = pNetworkAdapter->COMSETTER(BridgedInterface)(name.raw());
    27172717                        if (FAILED(rc)) throw rc;
    27182718                        break;
     
    27472747                        if (FAILED(rc)) throw rc;
    27482748                        /* Set the interface name to attach to */
    2749                         pNetworkAdapter->COMSETTER(HostOnlyInterface)(name.raw());
     2749                        rc = pNetworkAdapter->COMSETTER(HostOnlyInterface)(name.raw());
    27502750                        if (FAILED(rc)) throw rc;
    27512751                        break;
     
    27662766                rc = pNetworkAdapter->COMSETTER(AttachmentType)(NetworkAttachmentType_Generic);
    27672767                if (FAILED(rc)) throw rc;
     2768            }
     2769            /* Next test for NAT network interfaces */
     2770            else if (pvsys->strExtraConfigCurrent.endsWith("type=NATNetwork", Utf8Str::CaseInsensitive))
     2771            {
     2772                /* Attach to the right interface */
     2773                rc = pNetworkAdapter->COMSETTER(AttachmentType)(NetworkAttachmentType_NATNetwork);
     2774                if (FAILED(rc)) throw rc;
     2775                com::SafeIfaceArray<INATNetwork> nwNATNetworks;
     2776                rc = mVirtualBox->COMGETTER(NATNetworks)(ComSafeArrayAsOutParam(nwNATNetworks));
     2777                if (FAILED(rc)) throw rc;
     2778                // Pick the first NAT network (if there is any)
     2779                if (nwNATNetworks.size())
     2780                {
     2781                    Bstr name;
     2782                    rc = nwNATNetworks[0]->COMGETTER(NetworkName)(name.asOutParam());
     2783                    if (FAILED(rc)) throw rc;
     2784                    /* Set the NAT network name to attach to */
     2785                    rc = pNetworkAdapter->COMSETTER(NATNetwork)(name.raw());
     2786                    if (FAILED(rc)) throw rc;
     2787                    break;
     2788                }
    27682789            }
    27692790        }
     
    33253346        it1->fEnabled = false;
    33263347        if (!(   fKeepAllMACs
    3327               || (fKeepNATMACs && it1->mode == NetworkAttachmentType_NAT)))
     3348              || (fKeepNATMACs && it1->mode == NetworkAttachmentType_NAT)
     3349              || (fKeepNATMACs && it1->mode == NetworkAttachmentType_NATNetwork)))
    33283350            Host::generateMACAddress(it1->strMACAddress);
    33293351    }
  • trunk/src/VBox/Main/src-server/MachineImpl.cpp

    r48505 r48538  
    27522752    mData->m_strConfigFileFull.cloneTo(aFilePath);
    27532753    return S_OK;
    2754 }
    2755 
    2756 STDMETHODIMP Machine::COMSETTER(SettingsFilePath)(IN_BSTR aFilePath)
    2757 {
    2758     CheckComArgStrNotEmptyOrNull(aFilePath);
    2759 
    2760     AutoCaller autoCaller(this);
    2761     if (FAILED(autoCaller.rc())) return autoCaller.rc();
    2762 
    2763     ReturnComNotImplemented();
    27642754}
    27652755
     
    52875277
    52885278    return S_OK;
     5279}
     5280
     5281STDMETHODIMP Machine::SetSettingsFilePath(IN_BSTR aFilePath, IProgress **aProgress)
     5282{
     5283    CheckComArgStrNotEmptyOrNull(aFilePath);
     5284    CheckComArgOutPointerValid(aProgress);
     5285
     5286    AutoCaller autoCaller(this);
     5287    if (FAILED(autoCaller.rc())) return autoCaller.rc();
     5288
     5289    *aProgress = NULL;
     5290    ReturnComNotImplemented();
    52895291}
    52905292
  • trunk/src/VBox/Main/src-server/MediumImpl.cpp

    r48297 r48538  
    15431543}
    15441544
    1545 STDMETHODIMP Medium::COMSETTER(Location)(IN_BSTR aLocation)
    1546 {
    1547     CheckComArgStrNotEmptyOrNull(aLocation);
    1548 
    1549     AutoCaller autoCaller(this);
    1550     if (FAILED(autoCaller.rc())) return autoCaller.rc();
    1551 
    1552     AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS);
    1553 
    1554     /// @todo NEWMEDIA for file names, add the default extension if no extension
    1555     /// is present (using the information from the VD backend which also implies
    1556     /// that one more parameter should be passed to setLocation() requesting
    1557     /// that functionality since it is only allowed when called from this method
    1558 
    1559     /// @todo NEWMEDIA rename the file and set m->location on success, then save
    1560     /// the global registry (and local registries of portable VMs referring to
    1561     /// this medium), this will also require to add the mRegistered flag to data
    1562 
    1563     ReturnComNotImplemented();
    1564 }
    1565 
    15661545STDMETHODIMP Medium::COMGETTER(Name)(BSTR *aName)
    15671546{
     
    28922871
    28932872    return rc;
     2873}
     2874
     2875STDMETHODIMP Medium::SetLocation(IN_BSTR aLocation, IProgress **aProgress)
     2876{
     2877    CheckComArgStrNotEmptyOrNull(aLocation);
     2878    CheckComArgOutPointerValid(aProgress);
     2879
     2880    AutoCaller autoCaller(this);
     2881    if (FAILED(autoCaller.rc())) return autoCaller.rc();
     2882
     2883    AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS);
     2884
     2885    /// @todo NEWMEDIA for file names, add the default extension if no extension
     2886    /// is present (using the information from the VD backend which also implies
     2887    /// that one more parameter should be passed to setLocation() requesting
     2888    /// that functionality since it is only allowed when called from this method
     2889
     2890    /// @todo NEWMEDIA rename the file and set m->location on success, then save
     2891    /// the global registry (and local registries of portable VMs referring to
     2892    /// this medium), this will also require to add the mRegistered flag to data
     2893
     2894    *aProgress = NULL;
     2895    ReturnComNotImplemented();
    28942896}
    28952897
     
    59865988    pToken->Abandon();
    59875989    pToken.setNull();
    5988    
     5990
    59895991    if (FAILED(rc)) return rc;
    59905992
  • trunk/src/VBox/Main/src-server/NetworkAdapterImpl.cpp

    r42825 r48538  
    55
    66/*
    7  * Copyright (C) 2006-2012 Oracle Corporation
     7 * Copyright (C) 2006-2013 Oracle Corporation
    88 *
    99 * This file is part of VirtualBox Open Source Edition (OSE), as
     
    478478        }
    479479
     480        /* there must a NAT network name */
     481        if (mData->mNATNetwork.isEmpty())
     482        {
     483            Log(("NAT network name not defined, setting to default \"NatNetwork\"\n"));
     484            mData->mNATNetwork = "NatNetwork";
     485        }
     486
    480487        mData->mAttachmentType = aAttachmentType;
    481488
     
    526533    if (mData->mBridgedInterface != aBridgedInterface)
    527534    {
     535        /* if an empty/null string is to be set, bridged interface must be
     536         * turned off */
     537        if (   (aBridgedInterface == NULL || *aBridgedInterface == '\0')
     538            && mData->mAttachmentType == NetworkAttachmentType_Bridged)
     539        {
     540            return setError(E_FAIL,
     541                            tr("Empty or null bridged interface name is not valid"));
     542        }
     543
    528544        mData.backup();
    529545        mData->mBridgedInterface = aBridgedInterface;
     
    577593    if (mData->mHostOnlyInterface != aHostOnlyInterface)
    578594    {
     595        /* if an empty/null string is to be set, host only interface must be
     596         * turned off */
     597        if (   (aHostOnlyInterface == NULL || *aHostOnlyInterface == '\0')
     598            && mData->mAttachmentType == NetworkAttachmentType_HostOnly)
     599        {
     600            return setError(E_FAIL,
     601                            tr("Empty or null host only interface name is not valid"));
     602        }
     603
    579604        mData.backup();
    580605        mData->mHostOnlyInterface = aHostOnlyInterface;
     
    684709    if (mData->mNATNetwork != aNATNetwork)
    685710    {
     711        /* if an empty/null string is to be set, host only interface must be
     712         * turned off */
     713        if (   (aNATNetwork == NULL || *aNATNetwork == '\0')
     714            && mData->mAttachmentType == NetworkAttachmentType_NATNetwork)
     715        {
     716            return setError(E_FAIL,
     717                            tr("Empty or null NAT network name is not valid"));
     718        }
     719
    686720        mData.backup();
    687721        mData->mNATNetwork = aNATNetwork;
     
    695729        mlock.release();
    696730
    697         /* Changing the NAT network isn't allowed during runtime, therefore
    698          * no immediate replug in CFGM logic => changeAdapter=FALSE */
    699         mParent->onNetworkAdapterChange(this, FALSE);
     731        /* When changing the host adapter, adapt the CFGM logic to make this
     732         * change immediately effect and to notify the guest that the network
     733         * might have changed, therefore changeAdapter=TRUE. */
     734        mParent->onNetworkAdapterChange(this, TRUE);
    700735    }
    701736
     
    12091244    mData->mGenericDriver = data.strGenericDriver;
    12101245    mData->mGenericProperties = data.genericProperties;
     1246    mData->mNATNetwork = data.strNATNetworkName;
    12111247
    12121248    // leave the lock before setting attachment type
     
    12691305    data.genericProperties = mData->mGenericProperties;
    12701306
     1307    data.strNATNetworkName = mData->mNATNetwork;
     1308
    12711309    // after saving settings, we are no longer different from the XML on disk
    12721310    m_fModified = false;
  • trunk/src/VBox/Main/src-server/SystemPropertiesImpl.cpp

    r48004 r48538  
    390390        case NetworkAttachmentType_NAT:
    391391        case NetworkAttachmentType_Internal:
     392        case NetworkAttachmentType_NATNetwork:
    392393            /* chipset default is OK */
    393394            break;
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