Index: trunk/src/VBox/Frontends/VBoxManage/VBoxManageImport.cpp
===================================================================
--- trunk/src/VBox/Frontends/VBoxManage/VBoxManageImport.cpp	(revision 16600)
+++ trunk/src/VBox/Frontends/VBoxManage/VBoxManageImport.cpp	(revision 16601)
@@ -37,4 +37,5 @@
 
 #include <list>
+#include <map>
 #endif /* !VBOX_ONLY_DOCS */
 
@@ -49,4 +50,25 @@
 // funcs
 ///////////////////////////////////////////////////////////////////////////////
+
+typedef std::map<Utf8Str, Utf8Str> ArgsMap;         // pairs of strings like "-vmname" => "newvmname"
+typedef std::map<uint32_t, ArgsMap> ArgsMapsMap;   // map of maps, one for each virtual system, sorted by index
+
+static bool findArgValue(Utf8Str &strOut,
+                         const ArgsMap *pmapArgs,
+                         const Utf8Str &strKey)
+{
+    if (pmapArgs)
+    {
+        ArgsMap::const_iterator it;
+        it = pmapArgs->find(strKey);
+        if (it != pmapArgs->end())
+        {
+            strOut = it->second;
+            return true;
+        }
+    }
+
+    return false;
+}
 
 int handleImportAppliance(HandlerArg *a)
@@ -57,10 +79,52 @@
     bool fExecute = false;                  // if true, then we actually do the import (-exec argument)
 
-    for (int i = 0; i < a->argc; i++)
+    uint32_t ulCurVsys = (uint32_t)-1;
+
+    // for each -vsys X command, maintain a map of command line items
+    // (we'll parse them later after interpreting the OVF, when we can
+    // actually check whether they make sense semantically)
+    ArgsMapsMap mapArgsMapsPerVsys;
+
+    for (int i = 0;
+         i < a->argc;
+         ++i)
     {
-        if (!strcmp(a->argv[i], "-exec"))
+        Utf8Str strThisArg(a->argv[i]);
+        if (strThisArg == "-exec")
             fExecute = true;
+        else if (strThisArg == "-vsys")
+        {
+            if (++i < a->argc)
+            {
+                uint32_t ulVsys;
+                if (VINF_SUCCESS == (rc = Utf8Str(a->argv[i]).toInt(ulVsys)))       // don't use SUCCESS() macro, fail even on warnings
+                    ulCurVsys = ulVsys;
+                else
+                    return errorSyntax(USAGE_IMPORTAPPLIANCE, "Argument to -vsys option must be a non-negative number.");
+            }
+            else
+                return errorSyntax(USAGE_IMPORTAPPLIANCE, "Missing argument to -vsys option.");
+        }
+        else if (    (strThisArg == "-ostype")
+                  || (strThisArg == "-vmname")
+                  || (strThisArg == "-memory")
+                  || (strThisArg == "-ignore")
+                  || (strThisArg.substr(0, 5) == "-type")
+                  || (strThisArg.substr(0, 11) == "-controller")
+                )
+        {
+            if (ulCurVsys == (uint32_t)-1)
+                return errorSyntax(USAGE_IMPORTAPPLIANCE, "Option \"%s\" requires preceding -vsys argument.", strThisArg.c_str());
+
+            // store both this arg and the next one in the strings map for later parsing
+            if (++i < a->argc)
+                mapArgsMapsPerVsys[ulCurVsys][strThisArg] = Utf8Str(a->argv[i]);
+            else
+                return errorSyntax(USAGE_IMPORTAPPLIANCE, "Missing argument to \"%s\" option.", strThisArg.c_str());
+        }
+        else if (strThisArg[0] == '-')
+            return errorSyntax(USAGE_IMPORTAPPLIANCE, "Unknown option \"%s\".", strThisArg.c_str());
         else if (!strOvfFilename)
-            strOvfFilename = a->argv[i];
+            strOvfFilename = strThisArg;
         else
             return errorSyntax(USAGE_IMPORTAPPLIANCE, "Too many arguments for \"import\" command.");
@@ -76,5 +140,5 @@
         CHECK_ERROR_BREAK(a->virtualBox, OpenAppliance(bstrOvfFilename, appliance.asOutParam()));
 
-        RTPrintf("Interpreting...\n");
+        RTPrintf("Interpreting %s... ", strOvfFilename.c_str());
         CHECK_ERROR_BREAK(appliance, Interpret());
         RTPrintf("OK.\n");
@@ -96,7 +160,25 @@
         CHECK_ERROR_BREAK(appliance,
                           COMGETTER(VirtualSystemDescriptions)(ComSafeArrayAsOutParam(aVirtualSystemDescriptions)));
-        if (aVirtualSystemDescriptions.size() > 0)
-        {
-            for (unsigned i = 0; i < aVirtualSystemDescriptions.size(); ++i)
+
+        uint32_t cVirtualSystemDescriptions = aVirtualSystemDescriptions.size();
+
+        // match command line arguments with virtual system descriptions;
+        // this is only to sort out invalid indices at this time
+        ArgsMapsMap::const_iterator it;
+        for (it = mapArgsMapsPerVsys.begin();
+             it != mapArgsMapsPerVsys.end();
+             ++it)
+        {
+            uint32_t ulVsys = it->first;
+            if (ulVsys >= cVirtualSystemDescriptions)
+                return errorSyntax(USAGE_IMPORTAPPLIANCE,
+                                   "Invalid index %RI32 with -vsys option; the OVF contains only %RI32 virtual system(s).",
+                                   ulVsys, cVirtualSystemDescriptions);
+        }
+
+        // dump virtual system descriptions and match command-line arguments
+        if (cVirtualSystemDescriptions > 0)
+        {
+            for (unsigned i = 0; i < cVirtualSystemDescriptions; ++i)
             {
                 com::SafeArray<VirtualSystemDescriptionType_T> retTypes;
@@ -113,27 +195,61 @@
 
                 RTPrintf("Virtual system %i:\n", i);
+
+                // look up the corresponding command line options, if any
+                const ArgsMap *pmapArgs = NULL;
+                ArgsMapsMap::const_iterator itm = mapArgsMapsPerVsys.find(i);
+                if (itm != mapArgsMapsPerVsys.end())
+                    pmapArgs = &itm->second;
+
+//                     ArgsMap::const_iterator it3;
+//                     for (it3 = pmapArgs->begin();
+//                          it3 != pmapArgs->end();
+//                          ++it3)
+//                     {
+//                         RTPrintf("%s -> %s\n", it3->first.c_str(), it3->second.c_str());
+//                     }
+//                 }
+
+//                 Bstr bstrVMName;
+//                 Bstr bstrOSType;
+
+                // this collects the final values for setFinalValues()
+                com::SafeArray<BOOL> aEnabled(retTypes.size());
+                com::SafeArray<BSTR> aFinalValues(retTypes.size());
+
                 for (unsigned a = 0; a < retTypes.size(); ++a)
                 {
                     VirtualSystemDescriptionType_T t = retTypes[a];
 
-                    Bstr bstrVMname;
-                    Bstr bstrOstype;
-                    uint32_t ulMemMB;
-                    bool fUSB = false;
+                    Utf8Str strOverride;
+
+                    Bstr bstrFinalValue = aConfigValues[a];
 
                     switch (t)
                     {
                         case VirtualSystemDescriptionType_Name:
-                            bstrVMname = aConfigValues[a];
-                            RTPrintf("%2d: Suggested VM name \"%ls\""
-                                     "\n    (change with \"-vsys %d -vmname <name>\")\n",
-                                     a, bstrVMname.raw(), i);
+                            if (findArgValue(strOverride, pmapArgs, "-vmname"))
+                            {
+                                bstrFinalValue = strOverride;
+                                RTPrintf("%2d: VM name specified with -vmname: \"%ls\"\n",
+                                        a, bstrFinalValue.raw());
+                            }
+                            else
+                                RTPrintf("%2d: Suggested VM name \"%ls\""
+                                        "\n    (change with \"-vsys %d -vmname <name>\")\n",
+                                        a, bstrFinalValue.raw(), i);
                         break;
 
                         case VirtualSystemDescriptionType_OS:
-                            bstrOstype = aConfigValues[a];
-                            RTPrintf("%2d: Suggested OS type: \"%ls\""
-                                     "\n    (change with \"-vsys %d -ostype <type>\"; use \"list ostypes\" to list all)\n",
-                                     a, bstrOstype.raw(), i);
+                            if (findArgValue(strOverride, pmapArgs, "-ostype"))
+                            {
+                                bstrFinalValue = strOverride;
+                                RTPrintf("%2d: OS type specified with -ostype: \"%ls\"\n",
+                                        a, bstrFinalValue.raw());
+                            }
+                            else
+                                RTPrintf("%2d: Suggested OS type: \"%ls\""
+                                        "\n    (change with \"-vsys %d -ostype <type>\"; use \"list ostypes\" to list all)\n",
+                                        a, bstrFinalValue.raw(), i);
                         break;
 
@@ -144,7 +260,22 @@
 
                         case VirtualSystemDescriptionType_Memory:
-                            Utf8Str(Bstr(aConfigValues[a])).toInt(ulMemMB);
-                            RTPrintf("%2d: Guest memory: %u MB\n    (change with \"-vsys %d -memory <MB>\")\n",
-                                     a, ulMemMB, i);
+                        {
+                            if (findArgValue(strOverride, pmapArgs, "-memory"))
+                            {
+                                uint32_t ulMemMB;
+                                if (VINF_SUCCESS == strOverride.toInt(ulMemMB))
+                                {
+                                    bstrFinalValue = strOverride;
+                                    RTPrintf("%2d: Guest memory specified with -memory: %ls MB\n",
+                                             a, bstrFinalValue.raw());
+                                }
+                                else
+                                    return errorSyntax(USAGE_IMPORTAPPLIANCE,
+                                                       "Argument to -memory option must be a non-negative number.");
+                            }
+                            else
+                                RTPrintf("%2d: Guest memory: %ls MB\n    (change with \"-vsys %d -memory <MB>\")\n",
+                                         a, bstrFinalValue.raw(), i);
+                        }
                         break;
 
@@ -220,6 +351,14 @@
                         break;
                     }
+
+                    bstrFinalValue.detachTo(&aFinalValues[a]);
                 }
-            }
+
+                if (fExecute)
+                    CHECK_ERROR_BREAK(aVirtualSystemDescriptions[i],
+                                      SetFinalValues(ComSafeArrayAsInParam(aEnabled),
+                                                     ComSafeArrayAsInParam(aFinalValues)));
+
+            } // for (unsigned i = 0; i < cVirtualSystemDescriptions; ++i)
 
             if (fExecute)
Index: trunk/src/VBox/Main/ApplianceImpl.cpp
===================================================================
--- trunk/src/VBox/Main/ApplianceImpl.cpp	(revision 16600)
+++ trunk/src/VBox/Main/ApplianceImpl.cpp	(revision 16601)
@@ -2147,30 +2147,6 @@
 }
 
-STDMETHODIMP VirtualSystemDescription::DisableItem(ULONG index)
-{
-    AutoCaller autoCaller(this);
-    CheckComRCReturnRC(autoCaller.rc());
-
-    AutoWriteLock alock(this);
-
-    list<VirtualSystemDescriptionEntry>::iterator it;
-    for (it = m->descriptions.begin();
-         it != m->descriptions.end();
-         ++it)
-    {
-        VirtualSystemDescriptionEntry &e = *it;
-        if (e.ulIndex == index)
-        {
-            e.type = VirtualSystemDescriptionType_Ignore;
-            return S_OK;
-        }
-    }
-
-    return setError(VBOX_E_OBJECT_NOT_FOUND,
-                    tr("Array item index %d not found"),
-                    index);
-}
-
-STDMETHODIMP VirtualSystemDescription::SetFinalValues(ComSafeArrayIn(IN_BSTR, aFinalValues))
+STDMETHODIMP VirtualSystemDescription::SetFinalValues(ComSafeArrayIn(BOOL, aEnabled),
+                                                      ComSafeArrayIn(IN_BSTR, aFinalValues))
 {
     CheckComArgSafeArrayNotNull(aFinalValues);
@@ -2192,5 +2168,9 @@
     {
         VirtualSystemDescriptionEntry& vsde = *it;
-        vsde.strConfig = values[i];
+
+        if (aEnabled[i])
+            vsde.strConfig = values[i];
+        else
+            vsde.type = VirtualSystemDescriptionType_Ignore;
     }
 
Index: trunk/src/VBox/Main/idl/VirtualBox.xidl
===================================================================
--- trunk/src/VBox/Main/idl/VirtualBox.xidl	(revision 16600)
+++ trunk/src/VBox/Main/idl/VirtualBox.xidl	(revision 16601)
@@ -3122,31 +3122,35 @@
     </method>
 
-    <method name="disableItem">
-      <desc>
-        Disables part of the configuration, as represented by the array items returned by
-        <link to="getDescription" />. For example, to disable USB support for a given
-        virtual system, pass in the array item index of the USB controller; its type will
-        then be changed by this method from "USBController" to "Ignore".
-
-        This works only for items of the types HardDiskControllerIDE, HardDiskControllerSATA,
+    <method name="setFinalValues">
+      <desc>
+        This method allows the appliance's user to change the configuration for the virtual
+        system descriptions. For each array item returned from <link to="getDescription" />,
+        you must pass in one boolean value and one configuration value.
+
+        Each item in the boolean array determines whether the particular configuration item
+        should be enabled.
+        You can only disable items of the types HardDiskControllerIDE, HardDiskControllerSATA,
         HardDiskControllerSCSI, HardDiskImage, CDROM, Floppy, NetworkAdapter, USBController
         and SoundCard.
-      </desc>
-
-      <param name="index" type="unsigned long" dir="in">
-      </param>
-    </method>
-
-    <method name="SetFinalValues">
-      <desc></desc>
-
-      <param name="aFinaleValues" type="wstring" dir="in" safearray="yes">
+
+        For the configuration values, if you pass in the same array as returned
+        in the aConfigValues array from getDescription(), the configuration remains unchanged.
+        Please see the documentation for getDescription() for valid configuration values
+        for the individual array item types. If the corresponding item in the aEnabled array
+        is false, the configuration value is gnored.
+      </desc>
+
+      <param name="aEnabled" type="boolean" dir="in" safearray="yes">
         <desc></desc>
       </param>
 
+      <param name="aFinalValues" type="wstring" dir="in" safearray="yes">
+        <desc></desc>
+      </param>
+
     </method>
 
     <method name="getWarnings">
-      <desc>Returns textual warnings which occurs on the virtual system 
+      <desc>Returns textual warnings which occurs on the virtual system
       interpretion.</desc>
 
Index: trunk/src/VBox/Main/include/ApplianceImpl.h
===================================================================
--- trunk/src/VBox/Main/include/ApplianceImpl.h	(revision 16600)
+++ trunk/src/VBox/Main/include/ApplianceImpl.h	(revision 16601)
@@ -153,8 +153,7 @@
                               ComSafeArrayOut(BSTR, aConfigValues),
                               ComSafeArrayOut(BSTR, aExtraConfigValues));
-    STDMETHOD(DisableItem)(ULONG index);
-    STDMETHOD(SetFinalValues)(ComSafeArrayIn(IN_BSTR, aFinalValues));
 
-
+    STDMETHOD(SetFinalValues)(ComSafeArrayIn(BOOL, aEnabled),
+                              ComSafeArrayIn(IN_BSTR, aFinalValues));
 
     STDMETHOD(GetWarnings)(ComSafeArrayOut(BSTR, aWarnings));
