Index: trunk/src/VBox/Main/ApplianceImpl.cpp
===================================================================
--- trunk/src/VBox/Main/ApplianceImpl.cpp	(revision 29924)
+++ trunk/src/VBox/Main/ApplianceImpl.cpp	(revision 29925)
@@ -1057,8 +1057,8 @@
         bstr.cloneTo(&sfaOrigValues[i]);
 
-        bstr = vsde.strVbox;
+        bstr = vsde.strVboxCurrent;
         bstr.cloneTo(&sfaVboxValues[i]);
 
-        bstr = vsde.strExtraConfig;
+        bstr = vsde.strExtraConfigCurrent;
         bstr.cloneTo(&sfaExtraConfigValues[i]);
     }
@@ -1120,8 +1120,8 @@
         bstr.cloneTo(&sfaOrigValues[i]);
 
-        bstr = vsde->strVbox;
+        bstr = vsde->strVboxCurrent;
         bstr.cloneTo(&sfaVboxValues[i]);
 
-        bstr = vsde->strExtraConfig;
+        bstr = vsde->strExtraConfigCurrent;
         bstr.cloneTo(&sfaExtraConfigValues[i]);
     }
@@ -1168,6 +1168,6 @@
             case VirtualSystemDescriptionValueType_Reference: bstr = vsde->strRef; break;
             case VirtualSystemDescriptionValueType_Original: bstr = vsde->strOvf; break;
-            case VirtualSystemDescriptionValueType_Auto: bstr = vsde->strVbox; break;
-            case VirtualSystemDescriptionValueType_ExtraConfig: bstr = vsde->strExtraConfig; break;
+            case VirtualSystemDescriptionValueType_Auto: bstr = vsde->strVboxCurrent; break;
+            case VirtualSystemDescriptionValueType_ExtraConfig: bstr = vsde->strExtraConfigCurrent; break;
         }
 
@@ -1221,6 +1221,6 @@
         if (sfaEnabled[i])
         {
-            vsde.strVbox = sfaVboxValues[i];
-            vsde.strExtraConfig = sfaExtraConfigValues[i];
+            vsde.strVboxCurrent = sfaVboxValues[i];
+            vsde.strExtraConfigCurrent = sfaExtraConfigValues[i];
         }
         else
@@ -1270,6 +1270,10 @@
     vsde.strRef = strRef;
     vsde.strOvf = aOvfValue;
-    vsde.strVbox = aVboxValue;
-    vsde.strExtraConfig = strExtraConfig;
+    vsde.strVboxSuggested           // remember original value
+        = vsde.strVboxCurrent       // and set current value which can be overridden by setFinalValues()
+        = aVboxValue;
+    vsde.strExtraConfigSuggested
+        = vsde.strExtraConfigCurrent
+        = strExtraConfig;
     vsde.ulSizeMB = ulSizeMB;
 
Index: trunk/src/VBox/Main/ApplianceImplExport.cpp
===================================================================
--- trunk/src/VBox/Main/ApplianceImplExport.cpp	(revision 29924)
+++ trunk/src/VBox/Main/ApplianceImplExport.cpp	(revision 29925)
@@ -683,5 +683,5 @@
         throw setError(VBOX_E_NOT_SUPPORTED,
                         tr("Missing VM name"));
-    Utf8Str &strVMName = llName.front()->strVbox;
+    Utf8Str &strVMName = llName.front()->strVboxCurrent;
     pelmVirtualSystem->setAttribute("ovf:id", strVMName);
 
@@ -692,9 +692,9 @@
     std::list<VirtualSystemDescriptionEntry*> llVendorUrl = vsdescThis->findByType(VirtualSystemDescriptionType_VendorUrl);
     std::list<VirtualSystemDescriptionEntry*> llVersion = vsdescThis->findByType(VirtualSystemDescriptionType_Version);
-    bool fProduct = llProduct.size() && !llProduct.front()->strVbox.isEmpty();
-    bool fProductUrl = llProductUrl.size() && !llProductUrl.front()->strVbox.isEmpty();
-    bool fVendor = llVendor.size() && !llVendor.front()->strVbox.isEmpty();
-    bool fVendorUrl = llVendorUrl.size() && !llVendorUrl.front()->strVbox.isEmpty();
-    bool fVersion = llVersion.size() && !llVersion.front()->strVbox.isEmpty();
+    bool fProduct = llProduct.size() && !llProduct.front()->strVboxCurrent.isEmpty();
+    bool fProductUrl = llProductUrl.size() && !llProductUrl.front()->strVboxCurrent.isEmpty();
+    bool fVendor = llVendor.size() && !llVendor.front()->strVboxCurrent.isEmpty();
+    bool fVendorUrl = llVendorUrl.size() && !llVendorUrl.front()->strVboxCurrent.isEmpty();
+    bool fVersion = llVersion.size() && !llVersion.front()->strVboxCurrent.isEmpty();
     if (fProduct ||
         fProductUrl ||
@@ -723,13 +723,13 @@
         pelmAnnotationSection->createChild("Info")->addContent("Meta-information about the installed software");
         if (fProduct)
-            pelmAnnotationSection->createChild("Product")->addContent(llProduct.front()->strVbox);
+            pelmAnnotationSection->createChild("Product")->addContent(llProduct.front()->strVboxCurrent);
         if (fVendor)
-            pelmAnnotationSection->createChild("Vendor")->addContent(llVendor.front()->strVbox);
+            pelmAnnotationSection->createChild("Vendor")->addContent(llVendor.front()->strVboxCurrent);
         if (fVersion)
-            pelmAnnotationSection->createChild("Version")->addContent(llVersion.front()->strVbox);
+            pelmAnnotationSection->createChild("Version")->addContent(llVersion.front()->strVboxCurrent);
         if (fProductUrl)
-            pelmAnnotationSection->createChild("ProductUrl")->addContent(llProductUrl.front()->strVbox);
+            pelmAnnotationSection->createChild("ProductUrl")->addContent(llProductUrl.front()->strVboxCurrent);
         if (fVendorUrl)
-            pelmAnnotationSection->createChild("VendorUrl")->addContent(llVendorUrl.front()->strVbox);
+            pelmAnnotationSection->createChild("VendorUrl")->addContent(llVendorUrl.front()->strVboxCurrent);
     }
 
@@ -737,5 +737,5 @@
     std::list<VirtualSystemDescriptionEntry*> llDescription = vsdescThis->findByType(VirtualSystemDescriptionType_Description);
     if (llDescription.size() &&
-        !llDescription.front()->strVbox.isEmpty())
+        !llDescription.front()->strVboxCurrent.isEmpty())
     {
         /*  <Section ovf:required="false" xsi:type="ovf:AnnotationSection_Type">
@@ -754,5 +754,5 @@
 
         pelmAnnotationSection->createChild("Info")->addContent("A human-readable annotation");
-        pelmAnnotationSection->createChild("Annotation")->addContent(llDescription.front()->strVbox);
+        pelmAnnotationSection->createChild("Annotation")->addContent(llDescription.front()->strVboxCurrent);
     }
 
@@ -760,5 +760,5 @@
     std::list<VirtualSystemDescriptionEntry*> llLicense = vsdescThis->findByType(VirtualSystemDescriptionType_License);
     if (llLicense.size() &&
-        !llLicense.front()->strVbox.isEmpty())
+        !llLicense.front()->strVboxCurrent.isEmpty())
     {
         /* <EulaSection>
@@ -776,5 +776,5 @@
 
         pelmEulaSection->createChild("Info")->addContent("License agreement for the virtual system");
-        pelmEulaSection->createChild("License")->addContent(llLicense.front()->strVbox);
+        pelmEulaSection->createChild("License")->addContent(llLicense.front()->strVboxCurrent);
     }
 
@@ -879,6 +879,6 @@
                          desc.strRef.c_str(),
                          desc.strOvf.c_str(),
-                         desc.strVbox.c_str(),
-                         desc.strExtraConfig.c_str()));
+                         desc.strVboxCurrent.c_str(),
+                         desc.strExtraConfigCurrent.c_str()));
 
             ovf::ResourceType_T type = (ovf::ResourceType_T)0;      // if this becomes != 0 then we do stuff
@@ -918,5 +918,5 @@
                         strDescription = "Number of virtual CPUs";
                         type = ovf::ResourceType_Processor; // 3
-                        desc.strVbox.toInt(uTemp);
+                        desc.strVboxCurrent.toInt(uTemp);
                         lVirtualQuantity = (int32_t)uTemp;
                         strCaption = Utf8StrFmt("%d virtual CPU", lVirtualQuantity);     // without this ovftool won't eat the item
@@ -938,5 +938,5 @@
                         strDescription = "Memory Size";
                         type = ovf::ResourceType_Memory; // 4
-                        desc.strVbox.toInt(uTemp);
+                        desc.strVboxCurrent.toInt(uTemp);
                         lVirtualQuantity = (int32_t)(uTemp / _1M);
                         strAllocationUnits = "MegaBytes";
@@ -958,5 +958,5 @@
                         strDescription = "IDE Controller";
                         type = ovf::ResourceType_IDEController; // 5
-                        strResourceSubType = desc.strVbox;
+                        strResourceSubType = desc.strVboxCurrent;
 
                         if (!lIDEPrimaryControllerIndex)
@@ -1004,11 +1004,11 @@
                         lBusNumber = 0;
 
-                        if (    desc.strVbox.isEmpty()      // AHCI is the default in VirtualBox
-                                || (!desc.strVbox.compare("ahci", Utf8Str::CaseInsensitive))
-                            )
+                        if (    desc.strVboxCurrent.isEmpty()      // AHCI is the default in VirtualBox
+                             || (!desc.strVboxCurrent.compare("ahci", Utf8Str::CaseInsensitive))
+                           )
                             strResourceSubType = "AHCI";
                         else
                             throw setError(VBOX_E_NOT_SUPPORTED,
-                                            tr("Invalid config string \"%s\" in SATA controller"), desc.strVbox.c_str());
+                                            tr("Invalid config string \"%s\" in SATA controller"), desc.strVboxCurrent.c_str());
 
                         // remember this ID
@@ -1039,15 +1039,15 @@
                         lBusNumber = 0;
 
-                        if (    desc.strVbox.isEmpty()      // LsiLogic is the default in VirtualBox
-                             || (!desc.strVbox.compare("lsilogic", Utf8Str::CaseInsensitive))
+                        if (    desc.strVboxCurrent.isEmpty()      // LsiLogic is the default in VirtualBox
+                             || (!desc.strVboxCurrent.compare("lsilogic", Utf8Str::CaseInsensitive))
                             )
                             strResourceSubType = "lsilogic";
-                        else if (!desc.strVbox.compare("buslogic", Utf8Str::CaseInsensitive))
+                        else if (!desc.strVboxCurrent.compare("buslogic", Utf8Str::CaseInsensitive))
                             strResourceSubType = "buslogic";
-                        else if (!desc.strVbox.compare("lsilogicsas", Utf8Str::CaseInsensitive))
+                        else if (!desc.strVboxCurrent.compare("lsilogicsas", Utf8Str::CaseInsensitive))
                             strResourceSubType = "lsilogicsas";
                         else
                             throw setError(VBOX_E_NOT_SUPPORTED,
-                                            tr("Invalid config string \"%s\" in SCSI controller"), desc.strVbox.c_str());
+                                            tr("Invalid config string \"%s\" in SCSI controller"), desc.strVboxCurrent.c_str());
 
                         // remember this ID
@@ -1079,10 +1079,10 @@
 
                         // controller=<index>;channel=<c>
-                        size_t pos1 = desc.strExtraConfig.find("controller=");
-                        size_t pos2 = desc.strExtraConfig.find("channel=");
+                        size_t pos1 = desc.strExtraConfigCurrent.find("controller=");
+                        size_t pos2 = desc.strExtraConfigCurrent.find("channel=");
                         int32_t lControllerIndex = -1;
                         if (pos1 != Utf8Str::npos)
                         {
-                            RTStrToInt32Ex(desc.strExtraConfig.c_str() + pos1 + 11, NULL, 0, &lControllerIndex);
+                            RTStrToInt32Ex(desc.strExtraConfigCurrent.c_str() + pos1 + 11, NULL, 0, &lControllerIndex);
                             if (lControllerIndex == lIDEPrimaryControllerIndex)
                                 ulParent = idIDEPrimaryController;
@@ -1095,5 +1095,5 @@
                         }
                         if (pos2 != Utf8Str::npos)
-                            RTStrToInt32Ex(desc.strExtraConfig.c_str() + pos2 + 8, NULL, 0, &lAddressOnParent);
+                            RTStrToInt32Ex(desc.strExtraConfigCurrent.c_str() + pos2 + 8, NULL, 0, &lAddressOnParent);
 
                         LogFlowFunc(("HardDiskImage details: pos1=%d, pos2=%d, lControllerIndex=%d, lIDEPrimaryControllerIndex=%d, lIDESecondaryControllerIndex=%d, ulParent=%d, lAddressOnParent=%d\n",
@@ -1104,5 +1104,5 @@
                            )
                             throw setError(VBOX_E_NOT_SUPPORTED,
-                                            tr("Missing or bad extra config string in hard disk image: \"%s\""), desc.strExtraConfig.c_str());
+                                            tr("Missing or bad extra config string in hard disk image: \"%s\""), desc.strExtraConfigCurrent.c_str());
 
                         stack.mapDisks[strDiskID] = &desc;
@@ -1156,5 +1156,5 @@
                             * PCNet32 for our PCNet types & E1000 for the
                             * E1000 cards. */
-                        switch (desc.strVbox.toInt32())
+                        switch (desc.strVboxCurrent.toInt32())
                         {
                             case NetworkAdapterType_Am79C970A:
@@ -1470,5 +1470,5 @@
 
             // source path: where the VBox image is
-            const Utf8Str &strSrcFilePath = pDiskEntry->strVbox;
+            const Utf8Str &strSrcFilePath = pDiskEntry->strVboxCurrent;
             Bstr bstrSrcFilePath(strSrcFilePath);
             if (!RTPathExists(strSrcFilePath.c_str()))
Index: trunk/src/VBox/Main/ApplianceImplImport.cpp
===================================================================
--- trunk/src/VBox/Main/ApplianceImplImport.cpp	(revision 29924)
+++ trunk/src/VBox/Main/ApplianceImplImport.cpp	(revision 29925)
@@ -970,41 +970,4 @@
 
 /**
- * Used by Appliance::importMachineGeneric() to store
- * input parameters and rollback information.
- */
-struct Appliance::ImportStack
-{
-    // input pointers
-    const LocationInfo          &locInfo;           // ptr to location info from Appliance::importFS()
-    Utf8Str                     strSourceDir;       // directory where source files reside
-    const ovf::DiskImagesMap    &mapDisks;          // ptr to disks map in OVF
-    ComObjPtr<Progress>         &pProgress;         // progress object passed into Appliance::importFS()
-
-    // session (not initially created)
-    ComPtr<ISession>            pSession;           // session opened in Appliance::importFS() for machine manipulation
-    bool                        fSessionOpen;       // true if the pSession is currently open and needs closing
-
-    // a list of images that we created/imported; this is initially empty
-    // and will be cleaned up on errors
-    list<MyHardDiskAttachment>  llHardDiskAttachments;      // disks that were attached
-    list< ComPtr<IMedium> >     llHardDisksCreated;         // media that were created
-    list<Bstr>                  llMachinesRegistered;       // machines that were registered; list of string UUIDs
-
-    ImportStack(const LocationInfo &aLocInfo,
-                const ovf::DiskImagesMap &aMapDisks,
-                ComObjPtr<Progress> &aProgress)
-        : locInfo(aLocInfo),
-          mapDisks(aMapDisks),
-          pProgress(aProgress),
-          fSessionOpen(false)
-    {
-        // disk images have to be on the same place as the OVF file. So
-        // strip the filename out of the full file path
-        strSourceDir = aLocInfo.strPath;
-        strSourceDir.stripFilename();
-    }
-};
-
-/**
  * Checks if a manifest file exists in the given location and, if so, verifies
  * that the relevant files (the OVF XML and the disks referenced by it, as
@@ -1176,11 +1139,70 @@
             //    VirtualSystemDescriptionEntry and do import work
 
-            // @todo r=dj make this selection configurable at run-time, and from the GUI as well
-
+            // Even for the vbox:Machine case, there are a number of configuration items that will be taken from
+            // the OVF because otherwise the "override import parameters" mechanism in the GUI won't work.
+
+            // VM name
+            std::list<VirtualSystemDescriptionEntry*> vsdeName = vsdescThis->findByType(VirtualSystemDescriptionType_Name);
+            if (vsdeName.size() < 1)
+                throw setError(VBOX_E_FILE_ERROR,
+                               tr("Missing VM name"));
+            stack.strNameVBox = vsdeName.front()->strVboxCurrent;
+
+            // guest OS type
+            std::list<VirtualSystemDescriptionEntry*> vsdeOS;
+            vsdeOS = vsdescThis->findByType(VirtualSystemDescriptionType_OS);
+            if (vsdeOS.size() < 1)
+                throw setError(VBOX_E_FILE_ERROR,
+                               tr("Missing guest OS type"));
+            stack.strOsTypeVBox = vsdeOS.front()->strVboxCurrent;
+
+            // CPU count
+            std::list<VirtualSystemDescriptionEntry*> vsdeCPU = vsdescThis->findByType(VirtualSystemDescriptionType_CPU);
+            ComAssertMsgThrow(vsdeCPU.size() == 1, ("CPU count missing"), E_FAIL);
+            const Utf8Str &cpuVBox = vsdeCPU.front()->strVboxCurrent;
+            stack.cCPUs = (uint32_t)RTStrToUInt64(cpuVBox.c_str());
+            // We need HWVirt & IO-APIC if more than one CPU is requested
+            if (stack.cCPUs > 1)
+            {
+                stack.fForceHWVirt = true;
+                stack.fForceIOAPIC = true;
+            }
+
+            // RAM
+            std::list<VirtualSystemDescriptionEntry*> vsdeRAM = vsdescThis->findByType(VirtualSystemDescriptionType_Memory);
+            ComAssertMsgThrow(vsdeRAM.size() == 1, ("RAM size missing"), E_FAIL);
+            const Utf8Str &memoryVBox = vsdeRAM.front()->strVboxCurrent;
+            stack.ulMemorySizeMB = (uint32_t)RTStrToUInt64(memoryVBox.c_str());
+
+            // USB controller
+#ifdef VBOX_WITH_USB
+            /* USB Controller */
+            std::list<VirtualSystemDescriptionEntry*> vsdeUSBController = vsdescThis->findByType(VirtualSystemDescriptionType_USBController);
+            // USB support is enabled if there's at least one such entry; to disable USB support,
+            // the type of the USB item would have been changed to "ignore"
+            stack.fUSBEnabled = vsdeUSBController.size() > 0;
+#endif
+            // audio adapter
+            std::list<VirtualSystemDescriptionEntry*> vsdeAudioAdapter = vsdescThis->findByType(VirtualSystemDescriptionType_SoundCard);
+            /* @todo: we support one audio adapter only */
+            if (vsdeAudioAdapter.size() > 0)
+                stack.strAudioAdapter = vsdeAudioAdapter.front()->strVboxCurrent;
+
+            // import vbox:machine or OVF now
             if (vsdescThis->m->pConfig)
+                // vbox:Machine config
                 importVBoxMachine(vsdescThis, pNewMachine, stack);
             else
+                // generic OVF config
                 importMachineGeneric(vsysThis, vsdescThis, pNewMachine, stack);
 
+            // for the description of the new machine, always use the OVF entry, the user may have changed it in the import config
+            std::list<VirtualSystemDescriptionEntry*> vsdeDescription = vsdescThis->findByType(VirtualSystemDescriptionType_Description);
+            if (vsdeDescription.size())
+            {
+                const Utf8Str &strDescription = vsdeDescription.front()->strVboxCurrent;
+                rc = pNewMachine->COMSETTER(Description)(Bstr(strDescription));
+                if (FAILED(rc)) throw rc;
+            }
         } // for (it = pAppliance->m->llVirtualSystems.begin() ...
     }
@@ -1292,5 +1314,4 @@
              || RTPathExists(strTargetPath.c_str())
            )
-            /* This isn't allowed */
             throw setError(VBOX_E_FILE_ERROR,
                            tr("Destination file '%s' exists"),
@@ -1410,26 +1431,15 @@
                                      ImportStack &stack)
 {
-    /* Guest OS type */
-    std::list<VirtualSystemDescriptionEntry*> vsdeOS;
-    vsdeOS = vsdescThis->findByType(VirtualSystemDescriptionType_OS);
-    if (vsdeOS.size() < 1)
-        throw setError(VBOX_E_FILE_ERROR,
-                       tr("Missing guest OS type"));
-    const Utf8Str &strOsTypeVBox = vsdeOS.front()->strVbox;
-
-    /* Now that we know the base system get our internal defaults based on that. */
+    HRESULT rc;
+
+    // Get the instance of IGuestOSType which matches our string guest OS type so we
+    // can use recommended defaults for the new machine where OVF doesen't provice any
     ComPtr<IGuestOSType> osType;
-    HRESULT rc = mVirtualBox->GetGuestOSType(Bstr(strOsTypeVBox), osType.asOutParam());
+    rc = mVirtualBox->GetGuestOSType(Bstr(stack.strOsTypeVBox), osType.asOutParam());
     if (FAILED(rc)) throw rc;
 
     /* Create the machine */
-    /* First get the name */
-    std::list<VirtualSystemDescriptionEntry*> vsdeName = vsdescThis->findByType(VirtualSystemDescriptionType_Name);
-    if (vsdeName.size() < 1)
-        throw setError(VBOX_E_FILE_ERROR,
-                       tr("Missing VM name"));
-    const Utf8Str &strNameVBox = vsdeName.front()->strVbox;
-    rc = mVirtualBox->CreateMachine(Bstr(strNameVBox),
-                                    Bstr(strOsTypeVBox),
+    rc = mVirtualBox->CreateMachine(Bstr(stack.strNameVBox),
+                                    Bstr(stack.strOsTypeVBox),
                                     NULL,
                                     NULL,
@@ -1438,36 +1448,25 @@
     if (FAILED(rc)) throw rc;
 
-    // and the description
+    // set the description
     std::list<VirtualSystemDescriptionEntry*> vsdeDescription = vsdescThis->findByType(VirtualSystemDescriptionType_Description);
     if (vsdeDescription.size())
     {
-        const Utf8Str &strDescription = vsdeDescription.front()->strVbox;
+        const Utf8Str &strDescription = vsdeDescription.front()->strVboxCurrent;
         rc = pNewMachine->COMSETTER(Description)(Bstr(strDescription));
         if (FAILED(rc)) throw rc;
     }
 
-    /* CPU count */
-    std::list<VirtualSystemDescriptionEntry*> vsdeCPU = vsdescThis->findByType(VirtualSystemDescriptionType_CPU);
-    ComAssertMsgThrow(vsdeCPU.size() == 1, ("CPU count missing"), E_FAIL);
-    const Utf8Str &cpuVBox = vsdeCPU.front()->strVbox;
-    ULONG tmpCount = (ULONG)RTStrToUInt64(cpuVBox.c_str());
-    rc = pNewMachine->COMSETTER(CPUCount)(tmpCount);
+    // CPU count
+    rc = pNewMachine->COMSETTER(CPUCount)(stack.cCPUs);
     if (FAILED(rc)) throw rc;
-    bool fEnableIOApic = false;
-    /* We need HWVirt & IO-APIC if more than one CPU is requested */
-    if (tmpCount > 1)
+
+    if (stack.fForceHWVirt)
     {
         rc = pNewMachine->SetHWVirtExProperty(HWVirtExPropertyType_Enabled, TRUE);
         if (FAILED(rc)) throw rc;
-
-        fEnableIOApic = true;
-    }
-
-    /* RAM */
-    std::list<VirtualSystemDescriptionEntry*> vsdeRAM = vsdescThis->findByType(VirtualSystemDescriptionType_Memory);
-    ComAssertMsgThrow(vsdeRAM.size() == 1, ("RAM size missing"), E_FAIL);
-    const Utf8Str &memoryVBox = vsdeRAM.front()->strVbox;
-    ULONG tt = (ULONG)RTStrToUInt64(memoryVBox.c_str());
-    rc = pNewMachine->COMSETTER(MemorySize)(tt);
+    }
+
+    // RAM
+    rc = pNewMachine->COMSETTER(MemorySize)(stack.ulMemorySizeMB);
     if (FAILED(rc)) throw rc;
 
@@ -1486,5 +1485,5 @@
     // it will not mind finding an one later on, but if Windows was installed
     // _with_ an IOAPIC, it will bluescreen if it's not found
-    if (!fEnableIOApic)
+    if (!stack.fForceIOAPIC)
     {
         Bstr bstrFamilyId;
@@ -1492,8 +1491,8 @@
         if (FAILED(rc)) throw rc;
         if (bstrFamilyId == "Windows")
-            fEnableIOApic = true;
-    }
-
-    if (fEnableIOApic)
+            stack.fForceIOAPIC = true;
+    }
+
+    if (stack.fForceIOAPIC)
     {
         ComPtr<IBIOSSettings> pBIOSSettings;
@@ -1505,13 +1504,8 @@
     }
 
-    /* Audio Adapter */
-    std::list<VirtualSystemDescriptionEntry*> vsdeAudioAdapter = vsdescThis->findByType(VirtualSystemDescriptionType_SoundCard);
-    /* @todo: we support one audio adapter only */
-    if (vsdeAudioAdapter.size() > 0)
-    {
-        const Utf8Str& audioAdapterVBox = vsdeAudioAdapter.front()->strVbox;
-        if (audioAdapterVBox.compare("null", Utf8Str::CaseInsensitive) != 0)
-        {
-            uint32_t audio = RTStrToUInt32(audioAdapterVBox.c_str());
+    if (!stack.strAudioAdapter.isEmpty())
+        if (stack.strAudioAdapter.compare("null", Utf8Str::CaseInsensitive) != 0)
+        {
+            uint32_t audio = RTStrToUInt32(stack.strAudioAdapter.c_str());       // should be 0 for AC97
             ComPtr<IAudioAdapter> audioAdapter;
             rc = pNewMachine->COMGETTER(AudioAdapter)(audioAdapter.asOutParam());
@@ -1522,17 +1516,11 @@
             if (FAILED(rc)) throw rc;
         }
-    }
 
 #ifdef VBOX_WITH_USB
     /* USB Controller */
-    std::list<VirtualSystemDescriptionEntry*> vsdeUSBController = vsdescThis->findByType(VirtualSystemDescriptionType_USBController);
-    // USB support is enabled if there's at least one such entry; to disable USB support,
-    // the type of the USB item would have been changed to "ignore"
-    bool fUSBEnabled = vsdeUSBController.size() > 0;
-
     ComPtr<IUSBController> usbController;
     rc = pNewMachine->COMGETTER(USBController)(usbController.asOutParam());
     if (FAILED(rc)) throw rc;
-    rc = usbController->COMSETTER(Enabled)(fUSBEnabled);
+    rc = usbController->COMSETTER(Enabled)(stack.fUSBEnabled);
     if (FAILED(rc)) throw rc;
 #endif /* VBOX_WITH_USB */
@@ -1563,5 +1551,5 @@
             const VirtualSystemDescriptionEntry* pvsys = *nwIt;
 
-            const Utf8Str &nwTypeVBox = pvsys->strVbox;
+            const Utf8Str &nwTypeVBox = pvsys->strVboxCurrent;
             uint32_t tt1 = RTStrToUInt32(nwTypeVBox.c_str());
             ComPtr<INetworkAdapter> pNetworkAdapter;
@@ -1575,5 +1563,5 @@
 
             // default is NAT; change to "bridged" if extra conf says so
-            if (!pvsys->strExtraConfig.compare("type=Bridged", Utf8Str::CaseInsensitive))
+            if (!pvsys->strExtraConfigCurrent.compare("type=Bridged", Utf8Str::CaseInsensitive))
             {
                 /* Attach to the right interface */
@@ -1608,5 +1596,5 @@
             }
             /* Next test for host only interfaces */
-            else if (!pvsys->strExtraConfig.compare("type=HostOnly", Utf8Str::CaseInsensitive))
+            else if (!pvsys->strExtraConfigCurrent.compare("type=HostOnly", Utf8Str::CaseInsensitive))
             {
                 /* Attach to the right interface */
@@ -1658,5 +1646,5 @@
         if (FAILED(rc)) throw rc;
 
-        const char *pcszIDEType = vsdeHDCIDE.front()->strVbox.c_str();
+        const char *pcszIDEType = vsdeHDCIDE.front()->strVboxCurrent.c_str();
         if (!strcmp(pcszIDEType, "PIIX3"))
             rc = pController->COMSETTER(ControllerType)(StorageControllerType_PIIX3);
@@ -1680,5 +1668,5 @@
     {
         ComPtr<IStorageController> pController;
-        const Utf8Str &hdcVBox = vsdeHDCSATA.front()->strVbox;
+        const Utf8Str &hdcVBox = vsdeHDCSATA.front()->strVboxCurrent;
         if (hdcVBox == "AHCI")
         {
@@ -1703,5 +1691,5 @@
         StorageBus_T busType = StorageBus_SCSI;
         StorageControllerType_T controllerType;
-        const Utf8Str &hdcVBox = vsdeHDCSCSI.front()->strVbox;
+        const Utf8Str &hdcVBox = vsdeHDCSCSI.front()->strVboxCurrent;
         if (hdcVBox == "LsiLogic")
             controllerType = StorageControllerType_LsiLogic;
@@ -1895,5 +1883,5 @@
                 ComPtr<IMedium> pTargetHD;
                 importOneDiskImage(ovfDiskImage,
-                                   vsdeHD->strVbox,
+                                   vsdeHD->strVboxCurrent,
                                    pTargetHD,
                                    stack);
@@ -1921,5 +1909,5 @@
                                             mhda.lDevice);
 
-                Log(("Attaching disk %s to port %d on device %d\n", vsdeHD->strVbox.c_str(), mhda.lControllerPort, mhda.lDevice));
+                Log(("Attaching disk %s to port %d on device %d\n", vsdeHD->strVboxCurrent.c_str(), mhda.lControllerPort, mhda.lDevice));
 
                 rc = sMachine->AttachDevice(mhda.controllerType,    // wstring name
@@ -1971,5 +1959,8 @@
  *      replace the old UUID with the new one.
  *
- *  3)  Create the VirtualBox machine with the modfified machine config.
+ *  3)  Change the machine config according to the OVF virtual system descriptions, in case the
+ *      caller has modified them using setFinalValues().
+ *
+ *  4)  Create the VirtualBox machine with the modfified machine config.
  *
  * @param config
@@ -1989,5 +1980,46 @@
     if (FAILED(rc)) throw rc;
 
-    // step 1): scan the machine config for attachments
+    /*
+     *
+     * step 1): modify machine config according to OVF config, in case the user
+     * has modified them using setFinalValues()
+     *
+     */
+
+//     std::list<VirtualSystemDescriptionEntry*> llVSDEs;
+
+    config.hardwareMachine.cCPUs = stack.cCPUs;
+    config.hardwareMachine.ulMemorySizeMB = stack.ulMemorySizeMB;
+    if (stack.fForceIOAPIC)
+        config.hardwareMachine.fHardwareVirt = true;
+    if (stack.fForceIOAPIC)
+        config.hardwareMachine.biosSettings.fIOAPICEnabled = true;
+
+/*
+    <const name="HardDiskControllerIDE" value="14" />
+    <const name="HardDiskControllerSATA" value="15" />
+    <const name="HardDiskControllerSCSI" value="16" />
+    <const name="HardDiskControllerSAS" value="17" />
+    <const name="HardDiskImage" value="18" />
+    <const name="Floppy" value="19" />
+    <const name="CDROM" value="20" />
+    <const name="NetworkAdapter" value="21" />
+*/
+
+#ifdef VBOX_WITH_USB
+    // disable USB if user disabled USB
+    config.hardwareMachine.usbController.fEnabled = stack.fUSBEnabled;
+#endif
+
+    // audio adapter: only config is turning it off presently
+    if (stack.strAudioAdapter.isEmpty())
+        config.hardwareMachine.audioAdapter.fEnabled = false;
+
+    /*
+     *
+     * step 2: scan the machine config for media attachments
+     *
+     */
+
     for (settings::StorageControllersList::iterator sit = config.storageMachine.llStorageControllers.begin();
          sit != config.storageMachine.llStorageControllers.end();
@@ -2024,5 +2056,9 @@
                     searchUniqueDiskImageFilePath(strTargetPath);
 
-                    // step 2): for each attachment, import the disk...
+                    /*
+                     *
+                     * step 3: import disk
+                     *
+                     */
                     ComPtr<IMedium> pTargetHD;
                     importOneDiskImage(di,
@@ -2052,12 +2088,9 @@
     } // for (settings::StorageControllersList::const_iterator sit = config.storageMachine.llStorageControllers.begin();
 
-    // step 3): create the machine and have it import the config
-
-    // use the name that we computed in the OVF fields to avoid duplicates
-    std::list<VirtualSystemDescriptionEntry*> vsdeName = vsdescThis->findByType(VirtualSystemDescriptionType_Name);
-    if (vsdeName.size() < 1)
-        throw setError(VBOX_E_FILE_ERROR,
-                        tr("Missing VM name"));
-    const Utf8Str &strNameVBox = vsdeName.front()->strVbox;
+    /*
+     *
+     * step 4): create the machine and have it import the config
+     *
+     */
 
     ComObjPtr<Machine> pNewMachine;
@@ -2068,6 +2101,6 @@
     // instance that we created from the vbox:Machine
     rc = pNewMachine->init(mVirtualBox,
-                           strNameVBox,         // name from just above (can be suffixed to avoid duplicates)
-                           config);             // the whole machine config
+                           stack.strNameVBox,       // name from OVF preparations; can be suffixed to avoid duplicates, or changed by user
+                           config);                 // the whole machine config
     if (FAILED(rc)) throw rc;
 
Index: trunk/src/VBox/Main/include/ApplianceImpl.h
===================================================================
--- trunk/src/VBox/Main/include/ApplianceImpl.h	(revision 29924)
+++ trunk/src/VBox/Main/include/ApplianceImpl.h	(revision 29925)
@@ -185,6 +185,8 @@
     Utf8Str strRef;                         // reference number (hard disk controllers only)
     Utf8Str strOvf;                         // original OVF value (type-dependent)
-    Utf8Str strVbox;                        // configuration value (type-dependent)
-    Utf8Str strExtraConfig;                 // extra configuration key=value strings (type-dependent)
+    Utf8Str strVboxSuggested;               // configuration value (type-dependent); original value suggested by interpret()
+    Utf8Str strVboxCurrent;                 // configuration value (type-dependent); current value, either from interpret() or setFinalValue()
+    Utf8Str strExtraConfigSuggested;        // extra configuration key=value strings (type-dependent); original value suggested by interpret()
+    Utf8Str strExtraConfigCurrent;          // extra configuration key=value strings (type-dependent); current value, either from interpret() or setFinalValue()
 
     uint32_t ulSizeMB;                      // hard disk images only: a copy of ovf::DiskImage::ulSuggestedSizeMB
Index: trunk/src/VBox/Main/include/ApplianceImplPrivate.h
===================================================================
--- trunk/src/VBox/Main/include/ApplianceImplPrivate.h	(revision 29924)
+++ trunk/src/VBox/Main/include/ApplianceImplPrivate.h	(revision 29925)
@@ -132,4 +132,58 @@
 };
 
+/**
+ * Used by Appliance::importMachineGeneric() to store
+ * input parameters and rollback information.
+ */
+struct Appliance::ImportStack
+{
+    // input pointers
+    const LocationInfo              &locInfo;           // ptr to location info from Appliance::importFS()
+    Utf8Str                         strSourceDir;       // directory where source files reside
+    const ovf::DiskImagesMap        &mapDisks;          // ptr to disks map in OVF
+    ComObjPtr<Progress>             &pProgress;         // progress object passed into Appliance::importFS()
+
+    // input parameters from VirtualSystemDescriptions
+    Utf8Str                         strNameVBox;        // VM name
+    Utf8Str                         strOsTypeVBox;      // VirtualBox guest OS type as string
+    uint32_t                        cCPUs;              // CPU count
+    bool                            fForceHWVirt;       // if true, we force enabling hardware virtualization
+    bool                            fForceIOAPIC;       // if true, we force enabling the IOAPIC
+    uint32_t                        ulMemorySizeMB;     // virtual machien RAM in megabytes
+#ifdef VBOX_WITH_USB
+    bool                            fUSBEnabled;
+#endif
+    Utf8Str                         strAudioAdapter;    // if not empty, then the guest has audio enabled, and this is the decimal
+                                                        // representation of the audio adapter (should always be "0" for AC97 presently)
+
+    // session (not initially created)
+    ComPtr<ISession>                pSession;           // session opened in Appliance::importFS() for machine manipulation
+    bool                            fSessionOpen;       // true if the pSession is currently open and needs closing
+
+    // a list of images that we created/imported; this is initially empty
+    // and will be cleaned up on errors
+    std::list<MyHardDiskAttachment> llHardDiskAttachments;      // disks that were attached
+    std::list< ComPtr<IMedium> >    llHardDisksCreated;         // media that were created
+    std::list<Bstr>                 llMachinesRegistered;       // machines that were registered; list of string UUIDs
+
+    ImportStack(const LocationInfo &aLocInfo,
+                const ovf::DiskImagesMap &aMapDisks,
+                ComObjPtr<Progress> &aProgress)
+        : locInfo(aLocInfo),
+          mapDisks(aMapDisks),
+          pProgress(aProgress),
+          cCPUs(1),
+          fForceHWVirt(false),
+          fForceIOAPIC(false),
+          ulMemorySizeMB(0),
+          fSessionOpen(false)
+    {
+        // disk images have to be on the same place as the OVF file. So
+        // strip the filename out of the full file path
+        strSourceDir = aLocInfo.strPath;
+        strSourceDir.stripFilename();
+    }
+};
+
 ////////////////////////////////////////////////////////////////////////////////
 //
Index: trunk/src/VBox/Main/include/VirtualBoxImpl.h
===================================================================
--- trunk/src/VBox/Main/include/VirtualBoxImpl.h	(revision 29924)
+++ trunk/src/VBox/Main/include/VirtualBoxImpl.h	(revision 29925)
@@ -89,5 +89,5 @@
         COM_INTERFACE_ENTRY(ISupportErrorInfo)
         COM_INTERFACE_ENTRY(IVirtualBox)
-        COM_INTERFACE_ENTRY(IConnectionPointContainer) 
+        COM_INTERFACE_ENTRY(IConnectionPointContainer)
     END_COM_MAP()
 
Index: trunk/src/VBox/Main/include/ovfreader.h
===================================================================
--- trunk/src/VBox/Main/include/ovfreader.h	(revision 29924)
+++ trunk/src/VBox/Main/include/ovfreader.h	(revision 29925)
@@ -311,5 +311,5 @@
     iprt::MiniString    strName;                // copy of VirtualSystem/@id
 
-    iprt::MiniString    strDescription;         // copy of VirtualSystem/Info content
+    iprt::MiniString    strDescription;         // copy of VirtualSystem/AnnotationSection content, if any
 
     CIMOSType_T         cimos;
