VirtualBox

Changeset 91213 in vbox for trunk/src/VBox/Main/xml


Ignore:
Timestamp:
Sep 10, 2021 5:58:08 PM (3 years ago)
Author:
vboxsync
Message:

Main,FE/VBoxManage: Add the necessary Main API bits to control the trusted platform module settings as well as implementing support in VBoxManage, bugref:10075

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Main/xml/Settings.cpp

    r90828 r91213  
    28302830 * Constructor. Needs to set sane defaults which stand the test of time.
    28312831 */
     2832TpmSettings::TpmSettings() :
     2833    tpmType(TpmType_None)
     2834{
     2835}
     2836
     2837/**
     2838 * Check if all settings have default values.
     2839 */
     2840bool TpmSettings::areDefaultSettings() const
     2841{
     2842    return    tpmType     == TpmType_None
     2843           && strLocation.isEmpty();
     2844}
     2845
     2846/**
     2847 * Comparison operator. This gets called from MachineConfigFile::operator==,
     2848 * which in turn gets called from Machine::saveSettings to figure out whether
     2849 * machine settings have really changed and thus need to be written out to disk.
     2850 */
     2851bool TpmSettings::operator==(const TpmSettings &g) const
     2852{
     2853    return (this == &g)
     2854        || (   tpmType         == g.tpmType
     2855            && strLocation     == g.strLocation);
     2856}
     2857
     2858/**
     2859 * Constructor. Needs to set sane defaults which stand the test of time.
     2860 */
    28322861USBController::USBController() :
    28332862    enmType(USBControllerType_Null)
     
    35043533            && graphicsAdapter                == h.graphicsAdapter
    35053534            && usbSettings                    == h.usbSettings
     3535            && tpmSettings                    == h.tpmSettings
    35063536            && llNetworkAdapters              == h.llNetworkAdapters
    35073537            && llSerialPorts                  == h.llSerialPorts
     
    49244954                hw.storage.llStorageControllers.push_back(sctl);
    49254955            }
     4956        }
     4957        else if (pelmHwChild->nameEquals("TrustedPlatformModule"))
     4958        {
     4959            Utf8Str strTpmType;
     4960            if (pelmHwChild->getAttributeValue("type", strTpmType))
     4961            {
     4962                if (strTpmType == "None")
     4963                    hw.tpmSettings.tpmType = TpmType_None;
     4964                else if (strTpmType == "v1_2")
     4965                    hw.tpmSettings.tpmType = TpmType_v1_2;
     4966                else if (strTpmType == "v2_0")
     4967                    hw.tpmSettings.tpmType = TpmType_v2_0;
     4968                else if (strTpmType == "Host")
     4969                    hw.tpmSettings.tpmType = TpmType_Host;
     4970                else if (strTpmType == "Swtpm")
     4971                    hw.tpmSettings.tpmType = TpmType_Swtpm;
     4972                else
     4973                    throw ConfigFileError(this,
     4974                                          pelmHwChild,
     4975                                          N_("Invalid value '%s' in TrustedPlatformModule/@type"),
     4976                                          strTpmType.c_str());
     4977            }
     4978
     4979            pelmHwChild->getAttributeValue("location", hw.tpmSettings.strLocation);
    49264980        }
    49274981        else if (   (m->sv <= SettingsVersion_v1_14)
     
    63936447        if (hw.biosSettings.fSmbiosUuidLittleEndian)
    63946448            pelmBIOS->createChild("SmbiosUuidLittleEndian")->setAttribute("enabled", hw.biosSettings.fSmbiosUuidLittleEndian);
     6449    }
     6450
     6451    if (!hw.tpmSettings.areDefaultSettings())
     6452    {
     6453        xml::ElementNode *pelmTpm = pelmHardware->createChild("TrustedPlatformModule");
     6454
     6455        const char *pcszTpm;
     6456        switch (hw.tpmSettings.tpmType)
     6457        {
     6458            default:
     6459            case TpmType_None:
     6460                pcszTpm = "None";
     6461                break;
     6462            case TpmType_v1_2:
     6463                pcszTpm = "v1_2";
     6464                break;
     6465            case TpmType_v2_0:
     6466                pcszTpm = "v2_0";
     6467                break;
     6468            case TpmType_Host:
     6469                pcszTpm = "Host";
     6470                break;
     6471            case TpmType_Swtpm:
     6472                pcszTpm = "Swtpm";
     6473                break;
     6474        }
     6475        pelmTpm->setAttribute("type", pcszTpm);
     6476        pelmTpm->setAttribute("location", hw.tpmSettings.strLocation);
    63956477    }
    63966478
     
    76877769            return;
    76887770        }
     7771
     7772        // VirtualBox 6.2 adds a Trusted Platform Module.
     7773        if (   hardwareMachine.tpmSettings.tpmType != TpmType_None
     7774            || hardwareMachine.tpmSettings.strLocation.isNotEmpty())
     7775        {
     7776            m->sv = SettingsVersion_v1_19;
     7777            return;
     7778        }
    76897779    }
    76907780
Note: See TracChangeset for help on using the changeset viewer.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette