VirtualBox

Ignore:
Timestamp:
Aug 3, 2008 2:34:37 PM (17 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
33990
Message:

FE/VBoxManage: we need a mutable machine session to set properties

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Frontends/VBoxManage/VBoxManageGuestProp.cpp

    r11042 r11079  
    9393
    9494static int handleSetGuestProperty(int argc, char *argv[],
    95                                   ComPtr<IVirtualBox> virtualBox,
    96                                   ComPtr<ISession> session)
     95                                  ComPtr<IVirtualBox> aVirtualBox,
     96                                  ComPtr<ISession> aSession)
    9797{
    9898    HRESULT rc = S_OK;
     
    133133    ComPtr<IMachine> machine;
    134134    /* assume it's a UUID */
    135     rc = virtualBox->GetMachine(Guid(argv[0]), machine.asOutParam());
     135    rc = aVirtualBox->GetMachine(Guid(argv[0]), machine.asOutParam());
    136136    if (FAILED(rc) || !machine)
    137137    {
    138138        /* must be a name */
    139         CHECK_ERROR(virtualBox, FindMachine(Bstr(argv[0]), machine.asOutParam()));
     139        CHECK_ERROR(aVirtualBox, FindMachine(Bstr(argv[0]), machine.asOutParam()));
    140140    }
    141141    if (machine)
    142142    {
     143        Guid uuid;
     144        machine->COMGETTER(Id)(uuid.asOutParam());
     145
     146        /* open a session for the VM */
     147        CHECK_ERROR_RET (aVirtualBox, OpenSession(aSession, uuid), 1);
     148
     149        /* get the mutable session machine */
     150        aSession->COMGETTER(Machine)(machine.asOutParam());
     151
    143152        if ((NULL == pszValue) && (NULL == pszFlags))
    144153            CHECK_ERROR(machine, SetGuestPropertyValue(Bstr(pszName), NULL));
     
    149158        else
    150159            CHECK_ERROR(machine, SetGuestProperty(Bstr(pszName), Bstr(pszValue), Bstr(pszFlags)));
     160
     161        if (SUCCEEDED(rc))
     162            CHECK_ERROR(machine, SaveSettings());
     163
     164        aSession->Close();
    151165    }
    152166    return SUCCEEDED(rc) ? 0 : 1;
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