VirtualBox

Changeset 48538 in vbox


Ignore:
Timestamp:
Sep 19, 2013 3:17:43 PM (12 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
Files:
22 edited

Legend:

Unmodified
Added
Removed
  • trunk/include/VBox/settings.h

    r48406 r48538  
    202202        return (strLoopbackHostAddress == strAddr);
    203203    }
    204    
     204
    205205    bool operator == (uint32_t off)
    206206    {
     
    595595    com::Utf8Str                        strGenericDriver;
    596596    StringsMap                          genericProperties;
     597    com::Utf8Str                        strNATNetworkName;
    597598    uint32_t                            ulBootPriority;
    598599    com::Utf8Str                        strBandwidthGroup; // requires settings version 1.13 (VirtualBox 4.2)
  • trunk/src/VBox/Frontends/VBoxManage/VBoxManageControlVM.cpp

    r48406 r48538  
    761761                        CHECK_ERROR_RET(adapter, COMSETTER(AttachmentType)(NetworkAttachmentType_Generic), 1);
    762762                    }
     763                    else if (!strcmp(a->argv[2], "natnetwork"))
     764                    {
     765                        if (a->argc <= 3)
     766                        {
     767                            errorArgument("Missing argument to '%s'", a->argv[2]);
     768                            rc = E_FAIL;
     769                            break;
     770                        }
     771                        CHECK_ERROR_RET(adapter, COMSETTER(Enabled)(TRUE), 1);
     772                        CHECK_ERROR_RET(adapter, COMSETTER(NATNetwork)(Bstr(a->argv[3]).raw()), 1);
     773                        CHECK_ERROR_RET(adapter, COMSETTER(AttachmentType)(NetworkAttachmentType_NATNetwork), 1);
     774                    }
    763775                    /** @todo obsolete, remove eventually */
    764776                    else if (!strcmp(a->argv[2], "vde"))
     
    14581470                break;
    14591471            }
    1460            
     1472
    14611473        }
    14621474        else
  • trunk/src/VBox/Frontends/VBoxManage/VBoxManageHelp.cpp

    r48429 r48538  
    123123                           "%s list [--long|-l]%s vms|runningvms|ostypes|hostdvds|hostfloppies|\n"
    124124#if defined(VBOX_WITH_NETFLT)
    125                      "                            bridgedifs|hostonlyifs|dhcpservers|hostinfo|\n"
     125                     "                            intnets|bridgedifs|hostonlyifs|natnets|dhcpservers|\n"
    126126#else
    127                      "                            bridgedifs|dhcpservers|hostinfo|\n"
    128 #endif
    129                      "                            hostcpuids|hddbackends|hdds|dvds|floppies|\n"
     127                     "                            intnets|bridgedifs|natnets|dhcpservers|hostinfo|\n"
     128#endif
     129                     "                            hostinfo|hostcpuids|hddbackends|hdds|dvds|floppies|\n"
    130130                     "                            usbhost|usbfilters|systemproperties|extpacks|\n"
    131131                     "                            groups\n"
     
    217217#endif
    218218                     "|\n"
    219                      "                                        generic"
     219                     "                                        generic|natnetwork"
    220220                     "]\n"
    221221                     "                            [--nictype<1-N> Am79C970A|Am79C973"
     
    240240#endif
    241241                     "                            [--intnet<1-N> <network name>]\n"
     242                     "                            [--nat-network<1-N> <network name>]\n"
     243                     "                            [--nicgenericdrv<1-N> <driver>\n"
    242244                     "                            [--natnet<1-N> <network>|default]\n"
    243                      "                            [--nicgenericdrv<1-N> <driver>\n"
    244245                     "                            [--natsettings<1-N> [<mtu>],[<socksnd>],\n"
    245246                     "                                                [<sockrcv>],[<tcpsnd>],\n"
     
    440441                     "                            setlinkstate<1-N> on|off |\n"
    441442#if defined(VBOX_WITH_NETFLT)
    442                      "                            nic<1-N> null|nat|bridged|intnet|hostonly|generic"
    443                      "\n"
    444                      "                                     [<devicename>] |\n"
     443                     "                            nic<1-N> null|nat|bridged|intnet|hostonly|generic|\n"
     444                     "                                     natnetwork [<devicename>] |\n"
    445445#else /* !VBOX_WITH_NETFLT */
    446                      "                            nic<1-N> null|nat|bridged|intnet|generic\n"
     446                     "                            nic<1-N> null|nat|bridged|intnet|generic|natnetwork\n"
    447447                     "                                     [<devicename>] |\n"
    448448#endif /* !VBOX_WITH_NETFLT */
  • trunk/src/VBox/Frontends/VBoxManage/VBoxManageInfo.cpp

    r47991 r48538  
    10731073                        break;
    10741074                    }
     1075
    10751076                    case NetworkAttachmentType_Generic:
    10761077                    {
     
    11031104                        break;
    11041105                    }
     1106
     1107                    case NetworkAttachmentType_NATNetwork:
     1108                    {
     1109                        Bstr strNetwork;
     1110                        nic->COMGETTER(NATNetwork)(strNetwork.asOutParam());
     1111                        if (details == VMINFO_MACHINEREADABLE)
     1112                        {
     1113                            RTPrintf("nat-network%d=\"%ls\"\n", currentNIC + 1, strNetwork.raw());
     1114                            strAttachment = "natnetwork";
     1115                        }
     1116                        else
     1117                            strAttachment = Utf8StrFmt("NAT Network '%s'", Utf8Str(strNetwork).c_str());
     1118                        break;
     1119                    }
     1120
    11051121                    default:
    11061122                        strAttachment = "unknown";
  • trunk/src/VBox/Frontends/VBoxManage/VBoxManageList.cpp

    r48097 r48538  
    7676
    7777/**
     78 * List internal networks.
     79 *
     80 * @returns See produceList.
     81 * @param   pVirtualBox         Reference to the IVirtualBox smart pointer.
     82 */
     83static HRESULT listInternalNetworks(const ComPtr<IVirtualBox> pVirtualBox)
     84{
     85    HRESULT rc;
     86    com::SafeArray<BSTR> internalNetworks;
     87    CHECK_ERROR(pVirtualBox, COMGETTER(InternalNetworks)(ComSafeArrayAsOutParam(internalNetworks)));
     88    for (size_t i = 0; i < internalNetworks.size(); ++i)
     89    {
     90        RTPrintf("Name:        %ls\n", internalNetworks[i]);
     91    }
     92    return rc;
     93}
     94
     95
     96/**
    7897 * List network interfaces information (bridged/host only).
    7998 *
    8099 * @returns See produceList.
    81100 * @param   pVirtualBox         Reference to the IVirtualBox smart pointer.
     101 * @param   fIsBridged          Selects between listing host interfaces (for
     102 *                              use with bridging) or host only interfaces.
    82103 */
    83104static HRESULT listNetworkInterfaces(const ComPtr<IVirtualBox> pVirtualBox,
     
    283304
    284305        /* File extensions */
    285         com::SafeArray <BSTR> fileExtensions;
    286         com::SafeArray <DeviceType_T> deviceTypes;
     306        com::SafeArray<BSTR> fileExtensions;
     307        com::SafeArray<DeviceType_T> deviceTypes;
    287308        CHECK_ERROR(mediumFormats[i],
    288309                    DescribeFileExtensions(ComSafeArrayAsOutParam(fileExtensions), ComSafeArrayAsOutParam(deviceTypes)));
     
    296317
    297318        /* Configuration keys */
    298         com::SafeArray <BSTR> propertyNames;
    299         com::SafeArray <BSTR> propertyDescriptions;
    300         com::SafeArray <DataType_T> propertyTypes;
    301         com::SafeArray <ULONG> propertyFlags;
    302         com::SafeArray <BSTR> propertyDefaults;
     319        com::SafeArray<BSTR> propertyNames;
     320        com::SafeArray<BSTR> propertyDescriptions;
     321        com::SafeArray<DataType_T> propertyTypes;
     322        com::SafeArray<ULONG> propertyFlags;
     323        com::SafeArray<BSTR> propertyDefaults;
    303324        CHECK_ERROR(mediumFormats[i],
    304325                    DescribeProperties(ComSafeArrayAsOutParam(propertyNames),
     
    722743    kListHostDvds,
    723744    kListHostFloppies,
     745    kListInternalNetworks,
    724746    kListBridgedInterfaces,
    725747#if defined(VBOX_WITH_NETFLT)
     
    894916        }
    895917
     918        case kListInternalNetworks:
     919            rc = listInternalNetworks(pVirtualBox);
     920            break;
     921
    896922        case kListBridgedInterfaces:
    897923#if defined(VBOX_WITH_NETFLT)
     
    10381064                net->COMGETTER(Enabled)(&fEnabled);
    10391065                RTPrintf("Enabled:        %s\n", fEnabled ? "Yes" : "No");
    1040                
     1066
    10411067#define PRINT_STRING_ARRAY(title) \
    10421068                if (strs.size() > 0)    \
     
    10461072                    for (;j < strs.size(); ++j) \
    10471073                        RTPrintf("        %s\n", Utf8Str(strs[j]).c_str()); \
    1048                 } 
     1074                }
    10491075
    10501076                com::SafeArray<BSTR> strs;
     
    10961122        { "hostdvds",           kListHostDvds,           RTGETOPT_REQ_NOTHING },
    10971123        { "hostfloppies",       kListHostFloppies,       RTGETOPT_REQ_NOTHING },
     1124        { "intnets",            kListInternalNetworks,   RTGETOPT_REQ_NOTHING },
    10981125        { "hostifs",            kListBridgedInterfaces,  RTGETOPT_REQ_NOTHING }, /* backward compatibility */
    10991126        { "bridgedifs",         kListBridgedInterfaces,  RTGETOPT_REQ_NOTHING },
     
    11011128        { "hostonlyifs",        kListHostOnlyInterfaces, RTGETOPT_REQ_NOTHING },
    11021129#endif
     1130        { "natnetworks",        kListNatNetworks,        RTGETOPT_REQ_NOTHING },
     1131        { "natnets",            kListNatNetworks,        RTGETOPT_REQ_NOTHING },
    11031132        { "hostinfo",           kListHostInfo,           RTGETOPT_REQ_NOTHING },
    11041133        { "hostcpuids",         kListHostCpuIDs,         RTGETOPT_REQ_NOTHING },
     
    11131142        { "extpacks",           kListExtPacks,           RTGETOPT_REQ_NOTHING },
    11141143        { "groups",             kListGroups,             RTGETOPT_REQ_NOTHING },
    1115         { "natnetworks",        kListNatNetworks,        RTGETOPT_REQ_NOTHING },
    11161144    };
    11171145
     
    11411169            case kListHostDvds:
    11421170            case kListHostFloppies:
     1171            case kListInternalNetworks:
    11431172            case kListBridgedInterfaces:
    11441173#if defined(VBOX_WITH_NETFLT)
  • trunk/src/VBox/Frontends/VBoxManage/VBoxManageModifyVM.cpp

    r48406 r48538  
    113113    MODIFYVM_HOSTONLYADAPTER,
    114114    MODIFYVM_INTNET,
     115    MODIFYVM_GENERICDRV,
     116    MODIFYVM_NATNETWORKNAME,
    115117    MODIFYVM_NATNET,
    116     MODIFYVM_GENERICDRV,
    117118    MODIFYVM_NATBINDIP,
    118119    MODIFYVM_NATSETTINGS,
     
    273274    { "--hostonlyadapter",          MODIFYVM_HOSTONLYADAPTER,           RTGETOPT_REQ_STRING | RTGETOPT_FLAG_INDEX },
    274275    { "--intnet",                   MODIFYVM_INTNET,                    RTGETOPT_REQ_STRING | RTGETOPT_FLAG_INDEX },
     276    { "--nicgenericdrv",            MODIFYVM_GENERICDRV,                RTGETOPT_REQ_STRING | RTGETOPT_FLAG_INDEX },
     277    { "--nat-network",              MODIFYVM_NATNETWORKNAME,            RTGETOPT_REQ_STRING | RTGETOPT_FLAG_INDEX },
     278    { "--natnetwork",               MODIFYVM_NATNETWORKNAME,            RTGETOPT_REQ_STRING | RTGETOPT_FLAG_INDEX },
    275279    { "--natnet",                   MODIFYVM_NATNET,                    RTGETOPT_REQ_STRING | RTGETOPT_FLAG_INDEX },
    276     { "--nicgenericdrv",            MODIFYVM_GENERICDRV,                RTGETOPT_REQ_STRING | RTGETOPT_FLAG_INDEX },
    277280    { "--natbindip",                MODIFYVM_NATBINDIP,                 RTGETOPT_REQ_STRING | RTGETOPT_FLAG_INDEX },
    278281    { "--natsettings",              MODIFYVM_NATSETTINGS,               RTGETOPT_REQ_STRING | RTGETOPT_FLAG_INDEX },
     
    14091412                    CHECK_ERROR(nic, COMSETTER(AttachmentType)(NetworkAttachmentType_Generic));
    14101413                }
     1414                else if (!RTStrICmp(ValueUnion.psz, "natnetwork"))
     1415                {
     1416
     1417                    CHECK_ERROR(nic, COMSETTER(Enabled)(TRUE));
     1418                    CHECK_ERROR(nic, COMSETTER(AttachmentType)(NetworkAttachmentType_NATNetwork));
     1419                }
    14111420                else
    14121421                {
     
    14931502
    14941503                CHECK_ERROR(nic, COMSETTER(GenericDriver)(Bstr(ValueUnion.psz).raw()));
     1504                break;
     1505            }
     1506
     1507            case MODIFYVM_NATNETWORKNAME:
     1508            {
     1509                ComPtr<INetworkAdapter> nic;
     1510
     1511                CHECK_ERROR_BREAK(machine, GetNetworkAdapter(GetOptState.uIndex - 1, nic.asOutParam()));
     1512                ASSERT(nic);
     1513
     1514                CHECK_ERROR(nic, COMSETTER(NATNetwork)(Bstr(ValueUnion.psz).raw()));
    14951515                break;
    14961516            }
  • trunk/src/VBox/Frontends/VirtualBox/src/converter/UIConverterBackendCOM.cpp

    r48537 r48538  
    77
    88/*
    9  * Copyright (C) 2012 Oracle Corporation
     9 * Copyright (C) 2012-2013 Oracle Corporation
    1010 *
    1111 * This file is part of VirtualBox Open Source Edition (OSE), as
     
    290290        case KNetworkAttachmentType_HostOnly: return QApplication::translate("VBoxGlobal", "Host-only Adapter", "NetworkAttachmentType");
    291291        case KNetworkAttachmentType_Generic:  return QApplication::translate("VBoxGlobal", "Generic Driver", "NetworkAttachmentType");
     292        case KNetworkAttachmentType_NATNetwork:  return QApplication::translate("VBoxGlobal", "NAT Network", "NetworkAttachmentType");
    292293        default: AssertMsgFailed(("No text for %d", type)); break;
    293294    }
  • trunk/src/VBox/Frontends/VirtualBox/src/globals/VBoxGlobal.cpp

    r48534 r48538  
    13971397                    attType = attType.arg (tr ("Generic, '%1'",
    13981398                        "details report (network)").arg (adapter.GetGenericDriver()));
     1399                else if (type == KNetworkAttachmentType_NATNetwork)
     1400                    attType = attType.arg (tr ("NAT network, '%1'",
     1401                        "details report (network)").arg (adapter.GetNATNetwork()));
    13991402                else
    14001403                    attType = attType.arg (gpConverter->toString (type));
  • trunk/src/VBox/Frontends/VirtualBox/src/selector/graphics/details/UIGDetailsElements.cpp

    r48314 r48538  
    677677                            break;
    678678                        }
     679                        case KNetworkAttachmentType_NATNetwork:
     680                        {
     681                            strAttachmentType = strAttachmentType.arg(QApplication::translate("UIGDetails", "NAT Network, '%1'", "details (network)")
     682                                                                      .arg(adapter.GetNATNetwork()));
     683                            break;
     684                        }
    679685                        default:
    680686                        {
  • trunk/src/VBox/Frontends/VirtualBox/src/settings/machine/UIMachineSettingsNetwork.cpp

    r47944 r48538  
    77
    88/*
    9  * Copyright (C) 2008-2012 Oracle Corporation
     9 * Copyright (C) 2008-2013 Oracle Corporation
    1010 *
    1111 * This file is part of VirtualBox Open Source Edition (OSE), as
     
    3030#include "CNATEngine.h"
    3131#include "CHostNetworkInterface.h"
     32#include "CNATNetwork.h"
    3233
    3334/* Other VBox includes: */
     
    142143            adapterData.m_strGenericProperties = m_pGenericPropertiesTextEdit->toPlainText();
    143144            break;
     145        case KNetworkAttachmentType_NATNetwork:
     146            adapterData.m_strNATNetworkName = alternativeName();
     147            break;
    144148        default:
    145149            break;
     
    211215            {
    212216                message.second << tr("No generic driver is currently selected.");
     217                fPass = false;
     218            }
     219            break;
     220        }
     221        case KNetworkAttachmentType_NATNetwork:
     222        {
     223            if (alternativeName().isNull())
     224            {
     225                message.second << tr("No NAT network name is currently specified.");
    213226                fPass = false;
    214227            }
     
    289302        case KNetworkAttachmentType_Generic:
    290303            strResult = m_strGenericDriverName;
     304            break;
     305        case KNetworkAttachmentType_NATNetwork:
     306            strResult = m_strNATNetworkName;
    291307            break;
    292308        default:
     
    420436            break;
    421437        }
     438        case KNetworkAttachmentType_NATNetwork:
     439        {
     440            m_pAdapterNameCombo->setWhatsThis(tr("Enter the name of the NAT network that this network card "
     441                                                 "will be connected to. You can create and remove adapters "
     442                                                 "using the global network settings in the virtual machine "
     443                                                 "manager window."));
     444            m_pAdapterNameCombo->setEditable(true);
     445            break;
     446        }
    422447        default:
    423448        {
     
    480505                    emit sigTabUpdated();
    481506            }
     507            break;
     508        }
     509        case KNetworkAttachmentType_NATNetwork:
     510        {
     511            QString newName(m_pAdapterNameCombo->itemData(m_pAdapterNameCombo->currentIndex()).toString() == QString(pEmptyItemCode) ||
     512                            m_pAdapterNameCombo->currentText().isEmpty() ? QString() : m_pAdapterNameCombo->currentText());
     513            if (m_strNATNetworkName != newName)
     514                m_strNATNetworkName = newName;
    482515            break;
    483516        }
     
    560593        m_pAttachmentTypeComboBox->insertItem(iAttachmentTypeIndex, gpConverter->toString(KNetworkAttachmentType_Generic));
    561594        m_pAttachmentTypeComboBox->setItemData(iAttachmentTypeIndex, KNetworkAttachmentType_Generic);
     595        m_pAttachmentTypeComboBox->setItemData(iAttachmentTypeIndex, m_pAttachmentTypeComboBox->itemText(iAttachmentTypeIndex), Qt::ToolTipRole);
     596        ++iAttachmentTypeIndex;
     597        m_pAttachmentTypeComboBox->insertItem(iAttachmentTypeIndex, gpConverter->toString(KNetworkAttachmentType_NATNetwork));
     598        m_pAttachmentTypeComboBox->setItemData(iAttachmentTypeIndex, KNetworkAttachmentType_NATNetwork);
    562599        m_pAttachmentTypeComboBox->setItemData(iAttachmentTypeIndex, m_pAttachmentTypeComboBox->itemText(iAttachmentTypeIndex), Qt::ToolTipRole);
    563600        ++iAttachmentTypeIndex;
     
    659696            m_pAdapterNameCombo->insertItems(0, m_pParent->genericDriverList());
    660697            break;
     698        case KNetworkAttachmentType_NATNetwork:
     699            m_pAdapterNameCombo->insertItems(0, m_pParent->natNetworkList());
     700            break;
    661701        default:
    662702            break;
     
    670710            case KNetworkAttachmentType_Bridged:
    671711            case KNetworkAttachmentType_HostOnly:
     712            case KNetworkAttachmentType_NATNetwork:
    672713            {
    673714                /* If adapter list is empty => add 'Not selected' item: */
     
    706747        case KNetworkAttachmentType_HostOnly:
    707748        case KNetworkAttachmentType_Generic:
     749        case KNetworkAttachmentType_NATNetwork:
    708750        {
    709751            m_pAdapterNameCombo->setCurrentIndex(position(m_pAdapterNameCombo, alternativeName()));
     
    770812    refreshHostInterfaceList();
    771813    refreshGenericDriverList(true);
     814    refreshNATNetworkList();
    772815
    773816    /* For each network adapter: */
     
    917960                                updateGenericProperties(adapter, adapterData.m_strGenericProperties);
    918961                                break;
     962                            case KNetworkAttachmentType_NATNetwork:
     963                                adapter.SetNATNetwork(adapterData.m_strNATNetworkName);
     964                                break;
    919965                            default:
    920966                                break;
     
    10911137}
    10921138
     1139void UIMachineSettingsNetworkPage::refreshNATNetworkList()
     1140{
     1141    /* Reload NAT network list: */
     1142    m_natNetworkList.clear();
     1143    const CNATNetworkVector &nws = vboxGlobal().virtualBox().GetNATNetworks();
     1144    for (int i = 0; i < nws.size(); ++i)
     1145    {
     1146        const CNATNetwork &nw = nws[i];
     1147        m_natNetworkList << nw.GetNetworkName();
     1148    }
     1149}
     1150
    10931151/* static */
    10941152QStringList UIMachineSettingsNetworkPage::otherInternalNetworkList()
  • trunk/src/VBox/Frontends/VirtualBox/src/settings/machine/UIMachineSettingsNetwork.h

    r47944 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
     
    4444        , m_strGenericDriverName(QString())
    4545        , m_strGenericProperties(QString())
     46        , m_strNATNetworkName(QString())
    4647        , m_strMACAddress(QString())
    4748        , m_fCableConnected(false)
     
    6061               (m_strGenericDriverName == other.m_strGenericDriverName) &&
    6162               (m_strGenericProperties == other.m_strGenericProperties) &&
     63               (m_strNATNetworkName == other.m_strNATNetworkName) &&
    6264               (m_strMACAddress == other.m_strMACAddress) &&
    6365               (m_fCableConnected == other.m_fCableConnected) &&
     
    7880    QString m_strGenericDriverName;
    7981    QString m_strGenericProperties;
     82    QString m_strNATNetworkName;
    8083    QString m_strMACAddress;
    8184    bool m_fCableConnected;
     
    165168    QString m_strHostInterfaceName;
    166169    QString m_strGenericDriverName;
     170    QString m_strNATNetworkName;
    167171    UIPortForwardingDataList m_portForwardingRules;
    168172};
     
    186190    /* Generic driver list: */
    187191    const QStringList& genericDriverList() const { return m_genericDriverList; }
     192    /* NAT network list: */
     193    const QStringList& natNetworkList() const { return m_natNetworkList; }
    188194
    189195protected:
     
    225231    void refreshHostInterfaceList();
    226232    void refreshGenericDriverList(bool fFullRefresh = false);
     233    void refreshNATNetworkList();
    227234
    228235    /* Various static stuff: */
     
    240247    QStringList m_hostInterfaceList;
    241248    QStringList m_genericDriverList;
     249    QStringList m_natNetworkList;
    242250
    243251    /* Cache: */
  • trunk/src/VBox/Main/idl/VirtualBox.xidl

    r48505 r48538  
    13831383  /////////////////////////////////////////////////////////////////////////
    13841384  -->
    1385   <!-- This is experimental interface to LWIP based NAT server -->
     1385
    13861386  <interface name="INATNetwork" extends="$unknown"
    13871387    uuid="a63c75da-4c99-4e9d-8351-eb73651c18cc"
     
    25862586      <!-- Here we create a record in NAT network array with name
    25872587           and gateway/network parameters this information should
    2588            be enough for VBoxNet[Lwip]NAT and VBoxNetDHCP for
     2588           be enough for VBoxNetNAT and VBoxNetDHCP for
    25892589           servicing the guests.
    25902590      -->
     
    41224122  <interface
    41234123    name="IMachine" extends="$unknown"
    4124     uuid="8c931034-83f6-46b8-97f0-31e70d30402e"
     4124    uuid="7108c7c7-2c0a-47ee-9c69-022fe2a466bf"
    41254125    wsmap="managed"
    41264126    >
     
    45484548    </attribute>
    45494549
    4550     <attribute name="settingsFilePath" type="wstring">
     4550    <attribute name="settingsFilePath" type="wstring" readonly="yes">
    45514551      <desc>
    45524552        Full name of the file containing machine settings data.
    4553 
    4554         Currently, it is an error to change this property on any machine.
    4555         Later this will allow setting a new path for the settings file, with
    4556         automatic relocation of all files (including snapshots and disk images)
    4557         which are inside the base directory.
    4558 
    4559         <note>
    4560           Setting this property to @c null or to an empty string is forbidden.
    4561         </note>
    4562         <note>
    4563           When setting this property, the specified path must be absolute. When
    4564           reading this property, an absolute (full) path is always returned.
    4565         </note>
    4566         <note>
    4567           The specified path may not exist, it will be created when necessary.
    4568         </note>
    45694553      </desc>
    45704554    </attribute>
     
    63136297          New property value.
    63146298        </desc>
     6299      </param>
     6300    </method>
     6301
     6302    <method name="setSettingsFilePath">
     6303      <desc>
     6304        Currently, it is an error to change this property on any machine.
     6305        Later this will allow setting a new path for the settings file, with
     6306        automatic relocation of all files (including snapshots and disk images)
     6307        which are inside the base directory. This operation is only allowed
     6308        when there are no pending unsaved settings.
     6309
     6310        <note>
     6311          Setting this property to @c null or to an empty string is forbidden.
     6312          When setting this property, the specified path must be absolute.
     6313          The specified path may not exist, it will be created when necessary.
     6314        </note>
     6315
     6316        <result name="E_NOTIMPL">
     6317          The operation is not implemented yet.
     6318        </result>
     6319      </desc>
     6320
     6321      <param name="settingsFilePath" type="wstring" dir="in">
     6322        <desc>New settings file path, will be used to determine the new
     6323        location for the attached media if it is in the same directory or
     6324        below as the original settings file.</desc>
     6325      </param>
     6326      <param name="progress" type="IProgress" dir="return">
     6327        <desc>Progress object to track the operation completion.</desc>
    63156328      </param>
    63166329    </method>
     
    1304513058  <interface
    1304613059    name="IMedium" extends="$unknown"
    13047     uuid="8df5fc17-503a-4171-85bc-039b6f24d86b"
     13060    uuid="05f2bbb6-a3a6-4fb9-9b49-6d0dda7142ac"
    1304813061    wsmap="managed"
    1304913062    >
     
    1325913272    </attribute>
    1326013273
    13261     <attribute name="location" type="wstring">
     13274    <attribute name="location" type="wstring" readonly="yes">
    1326213275      <desc>
    1326313276        Location of the storage unit holding medium data.
     
    1326613279        types using regular files in a host's file system, the location
    1326713280        string is the full file name.
    13268 
    13269         Some medium types may support changing the storage unit location by
    13270         simply changing the value of this property. If this operation is not
    13271         supported, the implementation will return E_NOTIMPL in attempt to set
    13272         this attribute's value.
    13273 
    13274         When setting a value of the location attribute which is a regular file
    13275         in the host's file system, the given file name may be either relative to
    13276         the <link to="IVirtualBox::homeFolder">VirtualBox home folder</link> or
    13277         absolute. Note that if the given location specification does not contain
    13278         the file extension part then a proper default extension will be
    13279         automatically appended by the implementation depending on the medium type.
    1328013281      </desc>
    1328113282    </attribute>
     
    1418614187    <!-- other methods -->
    1418714188
     14189    <method name="setLocation">
     14190      <desc>
     14191        Changes the location of this medium. Some medium types may support
     14192        changing the storage unit location by simply changing the value of the
     14193        associated property. In this case the operation is performed
     14194        immediately, and @a progress is returning a @c null reference.
     14195        Otherwise on success there is a progress object returned, which
     14196        signals progress and completion of the operation. This distinction is
     14197        necessary because for some formats the operation is very fast, while
     14198        for others it can be very slow (moving the image file by copying all
     14199        data), and in the former case it'd be a waste of resources to create
     14200        a progress object which will immediately signal completion.
     14201
     14202        When setting a location for a medium which corresponds to a/several
     14203        regular file(s) in the host's file system, the given file name may be
     14204        either relative to the <link to="IVirtualBox::homeFolder">VirtualBox
     14205        home folder</link> or absolute. Note that if the given location
     14206        specification does not contain the file extension part then a proper
     14207        default extension will be automatically appended by the implementation
     14208        depending on the medium type.
     14209
     14210        <result name="E_NOTIMPL">
     14211          The operation is not implemented yet.
     14212        </result>
     14213        <result name="VBOX_E_NOT_SUPPORTED">
     14214          Medium format does not support changing the location.
     14215        </result>
     14216      </desc>
     14217      <param name="location" type="wstring" dir="in">
     14218        <desc>New location.</desc>
     14219      </param>
     14220      <param name="progress" type="IProgress" dir="return">
     14221        <desc>Progress object to track the operation completion.</desc>
     14222      </param>
     14223    </method>
     14224
    1418814225    <method name="compact">
    1418914226      <desc>
     
    1565115688  <enum
    1565215689    name="NetworkAttachmentType"
    15653     uuid="2ac4bc71-6b82-417a-acd1-f7426d2570d6"
     15690    uuid="524a8f9d-4b86-4b51-877d-1aa27c4ebeac"
    1565415691    >
    1565515692    <desc>
     
    1566515702    <const name="HostOnly"              value="4"/>
    1566615703    <const name="Generic"               value="5"/>
     15704    <const name="NATNetwork"            value="6"/>
    1566715705  </enum>
    1566815706
  • trunk/src/VBox/Main/include/MachineImpl.h

    r48505 r48538  
    457457    STDMETHOD(COMGETTER(USBDeviceFilters))(IUSBDeviceFilters * *aUSBDeviceFilters);
    458458    STDMETHOD(COMGETTER(SettingsFilePath))(BSTR *aFilePath);
    459     STDMETHOD(COMSETTER(SettingsFilePath))(IN_BSTR aFilePath);
    460459    STDMETHOD(COMGETTER(SettingsModified))(BOOL *aModified);
    461460    STDMETHOD(COMGETTER(SessionState))(SessionState_T *aSessionState);
     
    568567    STDMETHOD(GetHWVirtExProperty)(HWVirtExPropertyType_T property, BOOL *aVal);
    569568    STDMETHOD(SetHWVirtExProperty)(HWVirtExPropertyType_T property, BOOL aVal);
     569    STDMETHOD(SetSettingsFilePath)(IN_BSTR aFilePath, IProgress **aProgress);
    570570    STDMETHOD(SaveSettings)();
    571571    STDMETHOD(DiscardSettings)();
  • trunk/src/VBox/Main/include/MediumImpl.h

    r48297 r48538  
    106106    STDMETHOD(COMGETTER(Variant))(ComSafeArrayOut(MediumVariant_T, aVariant));
    107107    STDMETHOD(COMGETTER(Location))(BSTR *aLocation);
    108     STDMETHOD(COMSETTER(Location))(IN_BSTR aLocation);
    109108    STDMETHOD(COMGETTER(Name))(BSTR *aName);
    110109    STDMETHOD(COMGETTER(DeviceType))(DeviceType_T *aDeviceType);
     
    154153    STDMETHOD(CloneToBase)(IMedium *aTarget, ComSafeArrayIn(MediumVariant_T, aVariant),
    155154                           IProgress **aProgress);
     155    STDMETHOD(SetLocation)(IN_BSTR aLocation, IProgress **aProgress);
    156156    STDMETHOD(Compact)(IProgress **aProgress);
    157157    STDMETHOD(Resize)(LONG64 aLogicalSize, IProgress **aProgress);
  • trunk/src/VBox/Main/src-client/ConsoleImpl2.cpp

    r48528 r48538  
    48574857            }
    48584858
     4859            case NetworkAttachmentType_NATNetwork:
     4860            {
     4861                hrc = aNetworkAdapter->COMGETTER(NATNetwork)(bstr.asOutParam());            H();
     4862                if (!bstr.isEmpty())
     4863                {
     4864                    /** @todo add intnet prefix to separate namespaces, and add trunk if dealing with vboxnatX */
     4865                    InsertConfigString(pLunL0, "Driver", "IntNet");
     4866                    InsertConfigNode(pLunL0, "Config", &pCfg);
     4867                    InsertConfigString(pCfg, "Network", bstr);
     4868                    InsertConfigInteger(pCfg, "TrunkType", kIntNetTrunkType_WhateverNone);
     4869                    InsertConfigString(pCfg, "IfPolicyPromisc", pszPromiscuousGuestPolicy);
     4870                    networkName = bstr;
     4871                    trunkType = Bstr(TRUNKTYPE_WHATEVER);
     4872                }
     4873                break;
     4874            }
     4875
    48594876            default:
    48604877                AssertMsgFailed(("should not get here!\n"));
     
    48754892            case NetworkAttachmentType_NAT:
    48764893            case NetworkAttachmentType_Generic:
     4894            case NetworkAttachmentType_NATNetwork:
    48774895            {
    48784896                if (SUCCEEDED(hrc) && SUCCEEDED(rc))
  • 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;
  • trunk/src/VBox/Main/xml/Settings.cpp

    r48408 r48538  
    24222422        }
    24232423    }
     2424    else if (elmMode.nameEquals("NATNetwork"))
     2425    {
     2426        enmAttachmentType = NetworkAttachmentType_NATNetwork;
     2427
     2428        if (!elmMode.getAttributeValue("name", nic.strNATNetworkName))    // required network name
     2429            throw ConfigFileError(this, &elmMode, N_("Required NATNetwork/@name element is missing"));
     2430    }
    24242431    else if (elmMode.nameEquals("VDE"))
    24252432    {
     
    44604467            if (nic.mode != NetworkAttachmentType_Generic)
    44614468                buildNetworkXML(NetworkAttachmentType_Generic, *pelmDisabledNode, false, nic);
     4469            if (nic.mode != NetworkAttachmentType_NATNetwork)
     4470                buildNetworkXML(NetworkAttachmentType_NATNetwork, *pelmDisabledNode, false, nic);
    44624471            buildNetworkXML(nic.mode, *pelmAdapter, true, nic);
    44634472        }
     
    47724781                }
    47734782            }
     4783            break;
     4784
     4785        case NetworkAttachmentType_NATNetwork:
     4786            if (fEnabled || !nic.strNATNetworkName.isEmpty())
     4787                elmParent.createChild("NATNetwork")->setAttribute("name", nic.strNATNetworkName);
    47744788            break;
    47754789
     
    53195333    {
    53205334        // VirtualBox 4.3 adds default frontend setting, graphics controller
    5321         // setting, explicit long mode setting and video capturing.
     5335        // setting, explicit long mode setting, video capturing and NAT networking.
    53225336        if (   !hardwareMachine.strDefaultFrontend.isEmpty()
    53235337            || hardwareMachine.graphicsControllerType != GraphicsControllerType_VBoxVGA
     
    53255339            || machineUserData.ovIcon.length() > 0
    53265340            || hardwareMachine.fVideoCaptureEnabled)
     5341        {
    53275342            m->sv = SettingsVersion_v1_14;
     5343            return;
     5344        }
     5345        NetworkAdaptersList::const_iterator netit;
     5346        for (netit = hardwareMachine.llNetworkAdapters.begin();
     5347             netit != hardwareMachine.llNetworkAdapters.end();
     5348             ++netit)
     5349        {
     5350            if (netit->mode == NetworkAttachmentType_NATNetwork)
     5351            {
     5352                m->sv = SettingsVersion_v1_14;
     5353                break;
     5354            }
     5355        }
    53285356    }
    53295357
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