VirtualBox

Changeset 101164 in vbox for trunk/src/VBox/Main/src-server


Ignore:
Timestamp:
Sep 19, 2023 10:01:39 AM (17 months ago)
Author:
vboxsync
Message:

doc/manual,Frontends/VBoxManage,Main/{Global,GuestOSType,VirtualBox.xidl}:
Extend the OSType struct by including a new element named 'variant'
to provide further guest OS details and aid in guest OS categorization
for the GUI when creating VMs. Populate this field in the
Global::sOSTypes[] table for Linux using the distro name and for BSD
using the BSD flavour. Include the variant information in 'VBoxManage
list ostypes' and add a new 'VBoxManage list osvariants' subcommand.
Add new IVirtualBox methods for accessing the guest OS variant
information: getGuestOSVariantsByFamilyId() and getGuestOSDescsByVariant().
bugref:5936

Location:
trunk/src/VBox/Main/src-server
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Main/src-server/GuestOSTypeImpl.cpp

    r101139 r101164  
    113113    unconst(mFamilyID)                  = ostype.familyId;
    114114    unconst(mFamilyDescription)         = ostype.familyDescription;
     115    unconst(mOSVariant)                 = ostype.variant;
    115116    unconst(mID)                        = ostype.id;
    116117    unconst(mDescription)               = ostype.description;
     
    173174
    174175
     176HRESULT GuestOSType::getVariant(com::Utf8Str &aVariant)
     177{
     178    /* mOSVariant is constant during life time, no need to lock */
     179    aVariant = mOSVariant;
     180
     181    return S_OK;
     182}
     183
     184
    175185HRESULT GuestOSType::getId(com::Utf8Str &aId)
    176186{
  • trunk/src/VBox/Main/src-server/VirtualBoxImpl.cpp

    r101153 r101164  
    44024402
    44034403/**
     4404 * Walk the list of GuestOSType objects and return a list of all known guest
     4405 * OS families.
     4406 *
     4407 * @param aOSFamilies    Where to store the list of guest OS families.
     4408 *
     4409 * @note Locks the guest OS types list for reading.
     4410 */
     4411HRESULT VirtualBox::getGuestOSFamilies(std::vector<com::Utf8Str> &aOSFamilies)
     4412{
     4413    std::list<com::Utf8Str> allOSFamilies;
     4414
     4415    AutoReadLock alock(m->allGuestOSTypes.getLockHandle() COMMA_LOCKVAL_SRC_POS);
     4416
     4417    for (GuestOSTypesOList::const_iterator it = m->allGuestOSTypes.begin();
     4418         it != m->allGuestOSTypes.end(); ++it)
     4419    {
     4420        const Utf8Str &familyId = (*it)->i_familyId();
     4421        AssertMsg(!familyId.isEmpty(), ("familfyId must not be NULL"));
     4422        allOSFamilies.push_back(familyId);
     4423    }
     4424
     4425    /* throw out any duplicates */
     4426    allOSFamilies.sort();
     4427    allOSFamilies.unique();
     4428
     4429    aOSFamilies.resize(allOSFamilies.size());
     4430    size_t i = 0;
     4431    for (std::list<com::Utf8Str>::const_iterator it = allOSFamilies.begin();
     4432         it != allOSFamilies.end(); ++it, ++i)
     4433        aOSFamilies[i] = (*it);
     4434
     4435    return S_OK;
     4436}
     4437
     4438/**
     4439 * Walk the list of GuestOSType objects and return a list of guest OS
     4440 * variants which correspond to the supplied guest OS family ID.
     4441 *
     4442 * @param strOSFamily    Guest OS family ID.
     4443 * @param aOSVariants    Where to store the list of guest OS variants.
     4444 *
     4445 * @note Locks the guest OS types list for reading.
     4446 */
     4447HRESULT VirtualBox::getGuestOSVariantsByFamilyId(const Utf8Str &strOSFamily,
     4448                                                 std::vector<com::Utf8Str> &aOSVariants)
     4449{
     4450    std::list<com::Utf8Str> allOSVariants;
     4451
     4452    AutoReadLock alock(m->allGuestOSTypes.getLockHandle() COMMA_LOCKVAL_SRC_POS);
     4453
     4454    bool fFoundGuestOSType = false;
     4455    for (GuestOSTypesOList::const_iterator it = m->allGuestOSTypes.begin();
     4456         it != m->allGuestOSTypes.end(); ++it)
     4457    {
     4458        const Utf8Str &familyId = (*it)->i_familyId();
     4459        AssertMsg(!familyId.isEmpty(), ("familfyId must not be NULL"));
     4460        if (familyId.compare(strOSFamily, Utf8Str::CaseInsensitive) == 0)
     4461        {
     4462            fFoundGuestOSType = true;
     4463            break;
     4464        }
     4465    }
     4466
     4467    if (!fFoundGuestOSType)
     4468       return setError(VBOX_E_OBJECT_NOT_FOUND,
     4469                       tr("'%s' is not a valid guest OS family identifier."), strOSFamily.c_str());
     4470
     4471    for (GuestOSTypesOList::const_iterator it = m->allGuestOSTypes.begin();
     4472         it != m->allGuestOSTypes.end(); ++it)
     4473    {
     4474        const Utf8Str &familyId = (*it)->i_familyId();
     4475        AssertMsg(!familyId.isEmpty(), ("familfyId must not be NULL"));
     4476        if (familyId.compare(strOSFamily, Utf8Str::CaseInsensitive) == 0)
     4477        {
     4478            const Utf8Str &strOSVariant = (*it)->i_variant();
     4479            if (!strOSVariant.isEmpty())
     4480                allOSVariants.push_back(strOSVariant);
     4481        }
     4482    }
     4483
     4484    /* throw out any duplicates */
     4485    allOSVariants.sort();
     4486    allOSVariants.unique();
     4487
     4488    aOSVariants.resize(allOSVariants.size());
     4489    size_t i = 0;
     4490    for (std::list<com::Utf8Str>::const_iterator it = allOSVariants.begin();
     4491         it != allOSVariants.end(); ++it, ++i)
     4492        aOSVariants[i] = (*it);
     4493
     4494    return S_OK;
     4495}
     4496
     4497/**
     4498 * Walk the list of GuestOSType objects and return a list of guest OS
     4499 * descriptions which correspond to the supplied guest OS variant.
     4500 *
     4501 * @param strOSVariant     Guest OS variant.
     4502 * @param aGuestOSDescs    Where to store the list of guest OS descriptions..
     4503 *
     4504 * @note Locks the guest OS types list for reading.
     4505 */
     4506HRESULT VirtualBox::getGuestOSDescsByVariant(const Utf8Str &strOSVariant,
     4507                                             std::vector<com::Utf8Str> &aGuestOSDescs)
     4508{
     4509    std::list<com::Utf8Str> allOSDescs;
     4510
     4511    AutoReadLock alock(m->allGuestOSTypes.getLockHandle() COMMA_LOCKVAL_SRC_POS);
     4512
     4513    bool fFoundGuestOSVariant = false;
     4514    for (GuestOSTypesOList::const_iterator it = m->allGuestOSTypes.begin();
     4515         it != m->allGuestOSTypes.end(); ++it)
     4516    {
     4517        const Utf8Str &guestOSVariant = (*it)->i_variant();
     4518        /* Only some guest OS types have a populated variant value. */
     4519        if (guestOSVariant.isNotEmpty() &&
     4520            guestOSVariant.compare(strOSVariant, Utf8Str::CaseInsensitive) == 0)
     4521        {
     4522            fFoundGuestOSVariant = true;
     4523            break;
     4524        }
     4525    }
     4526
     4527    if (!fFoundGuestOSVariant)
     4528       return setError(VBOX_E_OBJECT_NOT_FOUND,
     4529                       tr("'%s' is not a valid guest OS variant."), strOSVariant.c_str());
     4530
     4531    for (GuestOSTypesOList::const_iterator it = m->allGuestOSTypes.begin();
     4532         it != m->allGuestOSTypes.end(); ++it)
     4533    {
     4534        const Utf8Str &guestOSVariant = (*it)->i_variant();
     4535        /* Only some guest OS types have a populated variant value. */
     4536        if (guestOSVariant.isNotEmpty() &&
     4537            guestOSVariant.compare(strOSVariant, Utf8Str::CaseInsensitive) == 0)
     4538        {
     4539            const Utf8Str &strOSDesc = (*it)->i_description();
     4540            allOSDescs.push_back(strOSDesc);
     4541        }
     4542    }
     4543
     4544    aGuestOSDescs.resize(allOSDescs.size());
     4545    size_t i = 0;
     4546    for (std::list<com::Utf8Str>::const_iterator it = allOSDescs.begin();
     4547         it != allOSDescs.end(); ++it, ++i)
     4548        aGuestOSDescs[i] = (*it);
     4549
     4550    return S_OK;
     4551}
     4552
     4553/**
    44044554 * Returns the constant pseudo-machine UUID that is used to identify the
    44054555 * global media registry.
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