VirtualBox

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


Ignore:
Timestamp:
May 29, 2020 6:43:11 PM (5 years ago)
Author:
vboxsync
Message:

OCI: (bugref:9469) cloud network integration code moved from Machine to Console, cloud network environment setup (cloud part).

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

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Main/Makefile.kmk

    r84540 r84618  
    571571        src-server/NATNetworkImpl.cpp \
    572572        $(if $(VBOX_WITH_CLOUD_NET), \
    573         src-server/CloudGateway.cpp \
    574573        src-server/CloudNetworkImpl.cpp \
    575574        ,) \
     
    10171016        $(VBOX_XML_SCHEMADEFS_CPP)
    10181017
     1018# Experimental cloud support
     1019ifdef VBOX_WITH_CLOUD_NET
     1020 VBoxC_DEFS += VBOX_WITH_CLOUD_NET
     1021 VBoxC_SOURCES += src-client/CloudGateway.cpp
     1022endif
     1023
    10191024# Audio bits.
    10201025VBoxC_SOURCES += \
  • trunk/src/VBox/Main/idl/VirtualBox.xidl

    r84564 r84618  
    2673326733
    2673426734
     26735  <interface name="ICloudNetworkEnvironmentInfo" extends="$unknown"
     26736             uuid="181dfb55-394d-44d3-9edb-af2c4472c40a"
     26737             wsmap="managed"
     26738             reservedAttributes="7">
     26739    <attribute name="tunnelNetworkId" type="wstring" readonly="yes"/>
     26740  </interface>
     26741
     26742
    2673526743  <interface name="ICloudMachine" extends="$unknown"
    2673626744             uuid="d8497a14-8fbf-11ea-aa85-2b4d110b053e"
     
    2692526933  <interface
    2692626934    name="ICloudClient" extends="$unknown"
    26927     uuid="5b047402-9648-11ea-9aa2-2f60bdea83dd"
     26935    uuid="5fa3a8db-1c4f-4cda-b8d4-7982ef60fefb"
    2692826936    wsmap="managed" reservedMethods="16" reservedAttributes="8"
    2692926937    >
     
    2734427352      <param name="gatewayInfo" type="ICloudNetworkGatewayInfo" dir="out">
    2734527353        <desc>Information about the started gateway.</desc>
     27354      </param>
     27355      <param name="progress" type="IProgress" dir="return">
     27356        <desc>Progress object to track the operation completion.</desc>
     27357      </param>
     27358    </method>
     27359
     27360    <method name="setupCloudNetworkEnvironment">
     27361      <param name="tunnelNetworkName" type="wstring" dir="in">
     27362        <desc>The name of tunnelling network to be created in the Cloud. If this parameter
     27363          is empty the default value "VirtualBox Tunneling Network" is assumed.</desc>
     27364      </param>
     27365      <param name="tunnelNetworkRange" type="wstring" dir="in">
     27366        <desc>The IP address range of tunnelling network to be created in the Cloud. If this
     27367          parameter is empty the default value "10.0.0.0/16" is assumed.</desc>
     27368      </param>
     27369      <param name="gatewayOsName" type="wstring" dir="in">
     27370        <desc>The name of the operating system to be used for cloud gateway instances.
     27371          The default value is "Oracle Linux".</desc>
     27372      </param>
     27373      <param name="gatewayOsVersion" type="wstring" dir="in">
     27374        <desc>The version of the operating system to be used for cloud gateway instances.
     27375          The default value is "7.8".</desc>
     27376      </param>
     27377      <param name="gatewayShape" type="wstring" dir="in">
     27378        <desc>The shape of cloud gateway instance. The default value is "VM.Standard2.1".</desc>
     27379      </param>
     27380      <param name="networkEnvironmentInfo" type="ICloudNetworkEnvironmentInfo" dir="out">
     27381        <desc>Information about the created network environment.</desc>
    2734627382      </param>
    2734727383      <param name="progress" type="IProgress" dir="return">
  • trunk/src/VBox/Main/include/ConsoleImpl.h

    r84342 r84618  
    3030# include "Recording.h"
    3131#endif
     32#ifdef VBOX_WITH_CLOUD_NET
     33#include "CloudGateway.h"
     34#endif /* VBOX_WITH_CLOUD_NET */
    3235
    3336class Guest;
     
    10921095#endif /* VBOX_WITH_RECORDING */
    10931096
     1097#ifdef VBOX_WITH_CLOUD_NET
     1098    GatewayInfo mGateways;
     1099#endif /* VBOX_WITH_CLOUD_NET */
     1100
    10941101    friend class VMTask;
    10951102    friend class ConsoleVRDPServer;
  • trunk/src/VBox/Main/include/MachineImpl.h

    r83169 r84618  
    4646# include "ThreadTask.h"
    4747#endif
    48 #ifdef VBOX_WITH_CLOUD_NET
    49 # include "CloudNetworkImpl.h"
    50 # include "CloudGateway.h"
    51 #endif /* VBOX_WITH_CLOUD_NET */
    5248
    5349// generated header
     
    204200        // list of files to delete in Delete(); this list is filled by Unregister()
    205201        std::list<Utf8Str>  llFilesToDelete;
    206 
    207 #ifdef VBOX_WITH_CLOUD_NET
    208         GatewayInfo         mGatewayInfo;
    209 #endif /* VBOX_WITH_CLOUD_NET */
    210202};
    211203
     
    764756    pm::CollectorGuest     *mCollectorGuest;
    765757#endif /* VBOX_WITH_RESOURCE_USAGE_API */
    766 
    767 #ifdef VBOX_WITH_CLOUD_NET
    768 HRESULT i_connectToCloudNetwork(ProgressProxy *aProgress);
    769 HRESULT i_disconnectFromCloudNetwork();
    770 HRESULT i_setMacAddress(int slot, const Utf8Str& strMac);
    771 #endif /* VBOX_WITH_CLOUD_NET */
    772758
    773759    Machine * const         mPeer;
  • trunk/src/VBox/Main/src-client/ConsoleImpl.cpp

    r82968 r84618  
    649649    }
    650650
     651#ifdef VBOX_WITH_CLOUD_NET
     652    {
     653        ComPtr<IVirtualBox> pVirtualBox;
     654        HRESULT rc = mMachine->COMGETTER(Parent)(pVirtualBox.asOutParam());
     655        AssertComRC(rc);
     656        if (SUCCEEDED(rc) && !pVirtualBox.isNull())
     657            stopGateways(pVirtualBox, mGateways);
     658    }
     659#endif /* VBOX_WITH_CLOUD_NET */
    651660    LogFlowThisFunc(("initFailed()=%d\n", autoUninitSpan.initFailed()));
    652661    if (mVmListener)
  • trunk/src/VBox/Main/src-client/ConsoleImpl2.cpp

    r83170 r84618  
    26302630            Assert(!macAddr.isEmpty());
    26312631            Utf8Str macAddrUtf8 = macAddr;
     2632#ifdef VBOX_WITH_CLOUD_NET
     2633            NetworkAttachmentType_T eAttachmentType;
     2634            hrc = networkAdapter->COMGETTER(AttachmentType)(&eAttachmentType);                 H();
     2635            if (eAttachmentType == NetworkAttachmentType_Cloud)
     2636            {
     2637                mGateways.setLocalMacAddress(macAddrUtf8);
     2638                /* We'll insert cloud MAC later, when it becomes known. */
     2639            }
     2640            else
     2641            {
     2642#endif
    26322643            char *macStr = (char*)macAddrUtf8.c_str();
    26332644            Assert(strlen(macStr) == 12);
     
    26462657            }
    26472658            InsertConfigBytes(pCfg, "MAC", &Mac, sizeof(Mac));
    2648 
     2659#ifdef VBOX_WITH_CLOUD_NET
     2660            }
     2661#endif
    26492662            /*
    26502663             * Check if the cable is supposed to be unplugged
     
    49854998        Bstr bstr;
    49864999
     5000#ifdef VBOX_WITH_CLOUD_NET
     5001        /* We'll need device's pCfg for cloud attachments */
     5002        PCFGMNODE pDevCfg = pCfg;
     5003#endif /* VBOX_WITH_CLOUD_NET */
     5004
    49875005#define H()         AssertLogRelMsgReturn(!FAILED(hrc), ("hrc=%Rhrc\n", hrc), VERR_MAIN_CONFIG_CONSTRUCTOR_COM_ERROR)
    49885006
     
    58235841            case NetworkAttachmentType_Cloud:
    58245842            {
    5825                 hrc = aNetworkAdapter->COMGETTER(CloudNetwork)(bstr.asOutParam());       H();
     5843                ComPtr<ICloudNetwork> network;
     5844                hrc = aNetworkAdapter->COMGETTER(CloudNetwork)(bstr.asOutParam());            H();
     5845                hrc = pMachine->COMGETTER(Name)(mGateways.mTargetVM.asOutParam());            H();
     5846                hrc = virtualBox->FindCloudNetworkByName(bstr.raw(), network.asOutParam());   H();
     5847                hrc = startGateways(virtualBox, network, mGateways);                          H();
     5848                InsertConfigBytes(pDevCfg, "MAC", &mGateways.mCloudMacAddress, sizeof(mGateways.mCloudMacAddress));
    58265849                if (!bstr.isEmpty())
    58275850                {
  • trunk/src/VBox/Main/src-server/MachineImpl.cpp

    r84395 r84618  
    5050#include "ExtPackManagerImpl.h"
    5151#include "MachineLaunchVMCommonWorker.h"
    52 #ifdef VBOX_WITH_CLOUD_NET
    53 #include "ApplianceImpl.h"
    54 #include "CloudGateway.h"
    55 #endif /* VBOX_WITH_CLOUD_NET */
    5652
    5753// generated header
     
    33353331        if (SUCCEEDED(rc))
    33363332        {
    3337 #ifdef VBOX_WITH_CLOUD_NET
    3338             i_connectToCloudNetwork(progress);
    3339 #endif /* VBOX_WITH_CLOUD_NET */
    3340 
    33413333            rc = i_launchVMProcess(control, strFrontend, aEnvironmentChanges, progress);
    33423334            if (SUCCEEDED(rc))
     
    73087300    return (mUSBControllers->size() > 0);
    73097301}
    7310 
    7311 #ifdef VBOX_WITH_CLOUD_NET
    7312 HRESULT Machine::i_setMacAddress(int slot, const Utf8Str& strMac)
    7313 {
    7314     Bstr macAddress = strMac;
    7315     ComPtr<ISession> session;
    7316     HRESULT hrc = session.createInprocObject(CLSID_Session);
    7317     if (FAILED(hrc))
    7318         LogRel(("OCI-NET: Failed to create a session. hrc=%x\n", hrc));
    7319 
    7320     hrc = lockMachine(session, LockType_Write);
    7321     if (FAILED(hrc))
    7322     {
    7323         LogRel(("OCI-NET: Failed to lock target VM for modifications. hrc=%x\n", hrc));
    7324         return hrc;
    7325     }
    7326 
    7327     ComPtr<IMachine> sessionMachine;
    7328     hrc = session->COMGETTER(Machine)(sessionMachine.asOutParam());
    7329     if (FAILED(hrc))
    7330     {
    7331         LogRel(("OCI-NET: Failed to obtain a mutable machine. hrc=%x\n", hrc));
    7332         return hrc;
    7333     }
    7334 
    7335     ComPtr<INetworkAdapter> networkAdapter;
    7336     hrc = sessionMachine->GetNetworkAdapter(slot, networkAdapter.asOutParam());
    7337     if (FAILED(hrc))
    7338     {
    7339         LogRel(("OCI-NET: Failed to locate the second network adapter. hrc=%x\n", hrc));
    7340         return hrc;
    7341     }
    7342 
    7343     hrc = networkAdapter->COMSETTER(MACAddress)(macAddress.raw());
    7344     if (FAILED(hrc))
    7345     {
    7346         LogRel(("OCI-NET: Failed to set network name for the second network adapter. hrc=%x\n", hrc));
    7347         return hrc;
    7348     }
    7349 
    7350     hrc = sessionMachine->SaveSettings();
    7351     if (FAILED(hrc))
    7352         LogRel(("OCI-NET: Failed to save 'lgw' settings. hrc=%x\n", hrc));
    7353 
    7354     session->UnlockMachine();
    7355 
    7356     return hrc;
    7357 }
    7358 
    7359 
    7360 HRESULT Machine::i_connectToCloudNetwork(ProgressProxy *aProgress)
    7361 {
    7362     LogFlowThisFuncEnter();
    7363     AssertReturn(aProgress, E_FAIL);
    7364 
    7365     HRESULT hrc = E_FAIL;
    7366     Bstr name;
    7367     int iSlot = -1;
    7368 
    7369     LogFlowThisFunc(("Checking if cloud network needs to be connected\n"));
    7370     for (int slot = 0; (unsigned)slot < mNetworkAdapters.size(); ++slot)
    7371     {
    7372         BOOL enabled;
    7373         hrc = mNetworkAdapters[slot]->COMGETTER(Enabled)(&enabled);
    7374         if (   FAILED(hrc)
    7375             || !enabled)
    7376             continue;
    7377 
    7378         NetworkAttachmentType_T type;
    7379         hrc = mNetworkAdapters[slot]->COMGETTER(AttachmentType)(&type);
    7380         if (   SUCCEEDED(hrc)
    7381             && type == NetworkAttachmentType_Cloud)
    7382         {
    7383             if (name.isNotEmpty())
    7384             {
    7385                 LogRel(("OCI-NET: VM '%s' uses multiple cloud network attachments. '%ls' will be ignored.\n",
    7386                         mUserData->s.strName.c_str(), name.raw()));
    7387                 continue;
    7388             }
    7389             hrc = mNetworkAdapters[slot]->COMGETTER(CloudNetwork)(name.asOutParam());
    7390             if (SUCCEEDED(hrc))
    7391             {
    7392                 LogRel(("OCI-NET: VM '%s' uses cloud network '%ls'\n",
    7393                         mUserData->s.strName.c_str(), name.raw()));
    7394                 iSlot = slot;
    7395             }
    7396         }
    7397     }
    7398     if (name.isNotEmpty())
    7399     {
    7400         LogFlowThisFunc(("Connecting to cloud network '%ls'...\n", name.raw()));
    7401         ComObjPtr<CloudNetwork> network;
    7402         hrc = mParent->i_findCloudNetworkByName(name, &network);
    7403         if (FAILED(hrc))
    7404         {
    7405             LogRel(("OCI-NET: Could not find cloud network '%ls'.\n", name.raw()));
    7406             return hrc;
    7407         }
    7408         Bstr MacAddress;
    7409         Utf8Str strMacAddress;
    7410         GatewayInfo gateways;
    7411         gateways.mTargetVM = mUserData->s.strName;
    7412         gateways.mAdapterSlot = iSlot;
    7413         hrc = mNetworkAdapters[iSlot]->COMGETTER(MACAddress)(MacAddress.asOutParam());
    7414         if (FAILED(hrc))
    7415         {
    7416             Host::i_generateMACAddress(strMacAddress);
    7417             LogRel(("OCI-NET: Failed to get MAC address of adapter connected to cloud network '%ls'.\n"
    7418                     "OCI-NET: Will use auto-generated '%s'.\n", name.raw(), strMacAddress.c_str()));
    7419         }
    7420         else
    7421             strMacAddress = MacAddress;
    7422         hrc = gateways.setLocalMacAddress(strMacAddress);
    7423         if (FAILED(hrc))
    7424         {
    7425             LogRel(("OCI-NET: Failed to obtain valid MAC address (%s) from cloud gateway '%ls'.\n",
    7426                     strMacAddress.c_str(), name.raw()));
    7427             return hrc;
    7428         }
    7429         hrc = startGateways(mParent, network, gateways);
    7430         /* We copy gateways structure unconditionally in order to be able to undo partially failed gateway setup. */
    7431         AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS);
    7432         mData->mGatewayInfo = gateways;
    7433         alock.release();
    7434         if (SUCCEEDED(hrc))
    7435         {
    7436             if (iSlot == -1)
    7437                 LogRel(("OCI-NET: No slot information available for cloud network attachment!\n"));
    7438             else
    7439             {
    7440                 hrc = i_setMacAddress(iSlot, gateways.getCloudMacAddressWithoutColons());
    7441                 if (SUCCEEDED(hrc))
    7442                     LogRel(("OCI-NET: Updated MAC address for '%s' to %RTmac\n",
    7443                             mUserData->s.strName.c_str(), &gateways.mCloudMacAddress));
    7444                 else
    7445                     LogRel(("OCI-NET: Failed to update MAC address for '%s' to %RTmac\n",
    7446                             mUserData->s.strName.c_str(), &gateways.mCloudMacAddress));
    7447             }
    7448         }
    7449     }
    7450     else
    7451         LogFlowThisFunc(("VM '%s' has no cloud network attachments.\n", mUserData->s.strName.c_str()));
    7452 
    7453     LogFlowThisFuncLeave();
    7454     return hrc;
    7455 }
    7456 
    7457 HRESULT Machine::i_disconnectFromCloudNetwork()
    7458 {
    7459     AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS);
    7460     GatewayInfo gateways(mData->mGatewayInfo);
    7461     mData->mGatewayInfo.setNull();
    7462     alock.release();
    7463 
    7464     HRESULT hrc = stopGateways(mParent, gateways);
    7465     /// @todo Restore original MAC address. I'd hate to wait here for Machine to power off though.
    7466     // i_setMacAddress(gateways.mAdapterSlot, gateways.getLocalMacAddressWithoutColons());
    7467     return hrc;
    7468 }
    7469 #endif /* VBOX_WITH_CLOUD_NET */
    74707302
    74717303
     
    1326413096    LogFlowThisFuncEnter();
    1326513097
    13266 #ifdef VBOX_WITH_CLOUD_NET
    13267     mPeer->i_disconnectFromCloudNetwork();
    13268 #endif /* VBOX_WITH_CLOUD_NET */
    13269 
    1327013098    AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS);
    1327113099
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