VirtualBox

Changeset 68917 in vbox for trunk/src/VBox/Main/include


Ignore:
Timestamp:
Sep 28, 2017 4:09:25 PM (8 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
118180
Message:

main/ovfreader: Ignore invalid InstanceID on Items where it doesn't matter. Fixes problem importing OVA containing placeholder string instead of number for the 'Memory' item. bugref:8997 Also fixed bogus EthernetPortItem and StorageItem object handling, instances would always be stripped down to VirtualHardwareItem after parsing and checking. Cleaned up the item parsing, reducing code duplication. Also reduced the excessive object copying during parsing a little.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Main/include/ovfreader.h

    r65066 r68917  
    2323#include "iprt/cpp/xml.h"
    2424#include <map>
     25#include <vector>
    2526
    2627namespace ovf
     
    492493struct VirtualSystem;
    493494
    494 typedef std::map<uint32_t, VirtualHardwareItem> HardwareItemsMap;
     495
     496/**
     497 * VirtualHardwareItem pointer vector with safe cleanup.
     498 *
     499 * We need to use object pointers because we also want EthernetPortItem and
     500 * StorageItems to go into the container.
     501 */
     502class HardwareItemVector : public std::vector<VirtualHardwareItem *>
     503{
     504public:
     505    HardwareItemVector() : std::vector<VirtualHardwareItem *>() { }
     506    ~HardwareItemVector()
     507    {
     508        for (iterator it = begin(); it != end(); ++it)
     509            delete(*it);
     510        clear();
     511    }
     512
     513    /* There is no copying of this vector.  We'd need something like shared_ptr for that. */
     514private:
     515    HardwareItemVector(const VirtualSystem &);
     516
     517};
    495518
    496519struct HardDiskController
     
    564587                                                // VMware Workstation 6.5 is "vmx-07"
    565588
    566     HardwareItemsMap    mapHardwareItems;       // map of virtual hardware items, sorted by unique instance ID
     589    HardwareItemVector  vecHardwareItems;       //< vector containing all virtual hardware items in parsing order.
    567590
    568591    uint64_t            ullMemorySize;          // always in bytes, copied from llHardwareItems; default = 0 (unspecified)
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