Changeset 84618 in vbox for trunk/src/VBox/Main
- Timestamp:
- May 29, 2020 6:43:11 PM (5 years ago)
- Location:
- trunk/src/VBox/Main
- Files:
-
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Main/Makefile.kmk
r84540 r84618 571 571 src-server/NATNetworkImpl.cpp \ 572 572 $(if $(VBOX_WITH_CLOUD_NET), \ 573 src-server/CloudGateway.cpp \574 573 src-server/CloudNetworkImpl.cpp \ 575 574 ,) \ … … 1017 1016 $(VBOX_XML_SCHEMADEFS_CPP) 1018 1017 1018 # Experimental cloud support 1019 ifdef VBOX_WITH_CLOUD_NET 1020 VBoxC_DEFS += VBOX_WITH_CLOUD_NET 1021 VBoxC_SOURCES += src-client/CloudGateway.cpp 1022 endif 1023 1019 1024 # Audio bits. 1020 1025 VBoxC_SOURCES += \ -
trunk/src/VBox/Main/idl/VirtualBox.xidl
r84564 r84618 26733 26733 26734 26734 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 26735 26743 <interface name="ICloudMachine" extends="$unknown" 26736 26744 uuid="d8497a14-8fbf-11ea-aa85-2b4d110b053e" … … 26925 26933 <interface 26926 26934 name="ICloudClient" extends="$unknown" 26927 uuid="5 b047402-9648-11ea-9aa2-2f60bdea83dd"26935 uuid="5fa3a8db-1c4f-4cda-b8d4-7982ef60fefb" 26928 26936 wsmap="managed" reservedMethods="16" reservedAttributes="8" 26929 26937 > … … 27344 27352 <param name="gatewayInfo" type="ICloudNetworkGatewayInfo" dir="out"> 27345 27353 <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> 27346 27382 </param> 27347 27383 <param name="progress" type="IProgress" dir="return"> -
trunk/src/VBox/Main/include/ConsoleImpl.h
r84342 r84618 30 30 # include "Recording.h" 31 31 #endif 32 #ifdef VBOX_WITH_CLOUD_NET 33 #include "CloudGateway.h" 34 #endif /* VBOX_WITH_CLOUD_NET */ 32 35 33 36 class Guest; … … 1092 1095 #endif /* VBOX_WITH_RECORDING */ 1093 1096 1097 #ifdef VBOX_WITH_CLOUD_NET 1098 GatewayInfo mGateways; 1099 #endif /* VBOX_WITH_CLOUD_NET */ 1100 1094 1101 friend class VMTask; 1095 1102 friend class ConsoleVRDPServer; -
trunk/src/VBox/Main/include/MachineImpl.h
r83169 r84618 46 46 # include "ThreadTask.h" 47 47 #endif 48 #ifdef VBOX_WITH_CLOUD_NET49 # include "CloudNetworkImpl.h"50 # include "CloudGateway.h"51 #endif /* VBOX_WITH_CLOUD_NET */52 48 53 49 // generated header … … 204 200 // list of files to delete in Delete(); this list is filled by Unregister() 205 201 std::list<Utf8Str> llFilesToDelete; 206 207 #ifdef VBOX_WITH_CLOUD_NET208 GatewayInfo mGatewayInfo;209 #endif /* VBOX_WITH_CLOUD_NET */210 202 }; 211 203 … … 764 756 pm::CollectorGuest *mCollectorGuest; 765 757 #endif /* VBOX_WITH_RESOURCE_USAGE_API */ 766 767 #ifdef VBOX_WITH_CLOUD_NET768 HRESULT i_connectToCloudNetwork(ProgressProxy *aProgress);769 HRESULT i_disconnectFromCloudNetwork();770 HRESULT i_setMacAddress(int slot, const Utf8Str& strMac);771 #endif /* VBOX_WITH_CLOUD_NET */772 758 773 759 Machine * const mPeer; -
trunk/src/VBox/Main/src-client/ConsoleImpl.cpp
r82968 r84618 649 649 } 650 650 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 */ 651 660 LogFlowThisFunc(("initFailed()=%d\n", autoUninitSpan.initFailed())); 652 661 if (mVmListener) -
trunk/src/VBox/Main/src-client/ConsoleImpl2.cpp
r83170 r84618 2630 2630 Assert(!macAddr.isEmpty()); 2631 2631 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 2632 2643 char *macStr = (char*)macAddrUtf8.c_str(); 2633 2644 Assert(strlen(macStr) == 12); … … 2646 2657 } 2647 2658 InsertConfigBytes(pCfg, "MAC", &Mac, sizeof(Mac)); 2648 2659 #ifdef VBOX_WITH_CLOUD_NET 2660 } 2661 #endif 2649 2662 /* 2650 2663 * Check if the cable is supposed to be unplugged … … 4985 4998 Bstr bstr; 4986 4999 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 4987 5005 #define H() AssertLogRelMsgReturn(!FAILED(hrc), ("hrc=%Rhrc\n", hrc), VERR_MAIN_CONFIG_CONSTRUCTOR_COM_ERROR) 4988 5006 … … 5823 5841 case NetworkAttachmentType_Cloud: 5824 5842 { 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)); 5826 5849 if (!bstr.isEmpty()) 5827 5850 { -
trunk/src/VBox/Main/src-server/MachineImpl.cpp
r84395 r84618 50 50 #include "ExtPackManagerImpl.h" 51 51 #include "MachineLaunchVMCommonWorker.h" 52 #ifdef VBOX_WITH_CLOUD_NET53 #include "ApplianceImpl.h"54 #include "CloudGateway.h"55 #endif /* VBOX_WITH_CLOUD_NET */56 52 57 53 // generated header … … 3335 3331 if (SUCCEEDED(rc)) 3336 3332 { 3337 #ifdef VBOX_WITH_CLOUD_NET3338 i_connectToCloudNetwork(progress);3339 #endif /* VBOX_WITH_CLOUD_NET */3340 3341 3333 rc = i_launchVMProcess(control, strFrontend, aEnvironmentChanges, progress); 3342 3334 if (SUCCEEDED(rc)) … … 7308 7300 return (mUSBControllers->size() > 0); 7309 7301 } 7310 7311 #ifdef VBOX_WITH_CLOUD_NET7312 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 else7421 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 else7439 {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 else7445 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 else7451 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 */7470 7302 7471 7303 … … 13264 13096 LogFlowThisFuncEnter(); 13265 13097 13266 #ifdef VBOX_WITH_CLOUD_NET13267 mPeer->i_disconnectFromCloudNetwork();13268 #endif /* VBOX_WITH_CLOUD_NET */13269 13270 13098 AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS); 13271 13099
Note:
See TracChangeset
for help on using the changeset viewer.