- Timestamp:
- Dec 5, 2018 3:24:38 PM (6 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/HostServices/GuestProperties/service.cpp
r75969 r75974 291 291 if (RTStrStartsWith(pszName, "/VirtualBox/HostInfo/")) 292 292 return true; 293 if (RTStrStartsWith(pszName, "/VirtualBox/VMInfo/")) 294 return true; 293 295 return false; 294 296 } … … 359 361 void * /* pvClient */) 360 362 { 363 /** @todo r=bird: Here be dragons! You must complete all calls for the client as 364 * it disconnects or we'll end wasting space... We're also confused after 365 * restoring state, but that's a bug somewhere in VMMDev, I think. */ 361 366 return VINF_SUCCESS; 362 367 } … … 416 421 417 422 void setHostVersionProps(); 423 void incrementCounterProp(const char *pszName); 418 424 static DECLCALLBACK(void) svcNotify(void *pvService, HGCMNOTIFYEVENT enmEvent); 419 425 … … 428 434 int getProperty(uint32_t cParms, VBOXHGCMSVCPARM paParms[]); 429 435 int setProperty(uint32_t cParms, VBOXHGCMSVCPARM paParms[], bool isGuest); 430 int setPropertyInternal(const char *pcszName, const char *pcszValue, uint32_t fFlags, uint64_t nsTimestamp, bool fIsGuest); 436 int setPropertyInternal(const char *pcszName, const char *pcszValue, uint32_t fFlags, uint64_t nsTimestamp, 437 bool fIsGuest = false); 431 438 int delProperty(uint32_t cParms, VBOXHGCMSVCPARM paParms[], bool isGuest); 432 439 int enumProps(uint32_t cParms, VBOXHGCMSVCPARM paParms[]); … … 779 786 * @thread HGCM 780 787 */ 781 int Service::setPropertyInternal(const char *pcszName, const char *pcszValue, uint32_t fFlags, uint64_t nsTimestamp, bool fIsGuest) 788 int Service::setPropertyInternal(const char *pcszName, const char *pcszValue, uint32_t fFlags, uint64_t nsTimestamp, 789 bool fIsGuest /*= false*/) 782 790 { 783 791 /* … … 1597 1605 } 1598 1606 1607 /** 1608 * Increments a counter property. 1609 * 1610 * It is assumed that this a transient property that is read-only to the guest. 1611 * 1612 * @param pszName The property name. 1613 * @throws std::bad_alloc if an out of memory condition occurs 1614 */ 1615 void Service::incrementCounterProp(const char *pszName) 1616 { 1617 /* Format the incremented value. */ 1618 char szValue[64]; 1619 Property *pProp = getPropertyInternal(pszName); 1620 if (pProp) 1621 { 1622 uint64_t uValue = RTStrToUInt64(pProp->mValue.c_str()); 1623 RTStrFormatU64(szValue, sizeof(szValue), uValue + 1, 10, 0, 0, 0); 1624 } 1625 else 1626 { 1627 szValue[0] = '1'; 1628 szValue[1] = '\0'; 1629 } 1630 1631 /* Set it. */ 1632 setPropertyInternal(pszName, szValue, GUEST_PROP_F_TRANSIENT | GUEST_PROP_F_RDONLYGUEST, getCurrentTimestamp()); 1633 } 1599 1634 1600 1635 /** … … 1608 1643 * version comparison. */ 1609 1644 setPropertyInternal("/VirtualBox/HostInfo/VBoxVer", VBOX_VERSION_STRING_RAW, 1610 GUEST_PROP_F_TRANSIENT | GUEST_PROP_F_RDONLYGUEST, nsTimestamp , false /*fIsGuest*/);1645 GUEST_PROP_F_TRANSIENT | GUEST_PROP_F_RDONLYGUEST, nsTimestamp); 1611 1646 1612 1647 /* Set the full VBox version string as a guest property. Can contain vendor-specific 1613 1648 * information/branding and/or pre-release tags. */ 1614 1649 setPropertyInternal("/VirtualBox/HostInfo/VBoxVerExt", VBOX_VERSION_STRING, 1615 GUEST_PROP_F_TRANSIENT | GUEST_PROP_F_RDONLYGUEST, nsTimestamp , false /*fIsGuest*/);1650 GUEST_PROP_F_TRANSIENT | GUEST_PROP_F_RDONLYGUEST, nsTimestamp); 1616 1651 1617 1652 /* Set the VBox SVN revision as a guest property */ 1618 1653 setPropertyInternal("/VirtualBox/HostInfo/VBoxRev", RTBldCfgRevisionStr(), 1619 GUEST_PROP_F_TRANSIENT | GUEST_PROP_F_RDONLYGUEST, nsTimestamp , false /*fIsGuest*/);1654 GUEST_PROP_F_TRANSIENT | GUEST_PROP_F_RDONLYGUEST, nsTimestamp); 1620 1655 } 1621 1656 … … 1629 1664 AssertPtrReturnVoid(pThis); 1630 1665 1631 /* Make sure the host version properties have been touched and are 1632 up-to-date after a restore: */ 1633 if ( !pThis->m_fSetHostVersionProps 1634 && (enmEvent == HGCMNOTIFYEVENT_RESUME || enmEvent == HGCMNOTIFYEVENT_POWER_ON)) 1635 { 1636 pThis->setHostVersionProps(); 1637 pThis->m_fSetHostVersionProps = true; 1638 } 1639 1640 /** @todo add suspend/resume property? */ 1641 /** @todo add reset counter? */ 1666 try 1667 { 1668 /* Make sure the host version properties have been touched and are 1669 up-to-date after a restore: */ 1670 if ( !pThis->m_fSetHostVersionProps 1671 && (enmEvent == HGCMNOTIFYEVENT_RESUME || enmEvent == HGCMNOTIFYEVENT_POWER_ON)) 1672 { 1673 pThis->setHostVersionProps(); 1674 pThis->m_fSetHostVersionProps = true; 1675 } 1676 1677 if (enmEvent == HGCMNOTIFYEVENT_RESUME) 1678 pThis->incrementCounterProp("/VirtualBox/VMInfo/ResumeCounter"); 1679 1680 if (enmEvent == HGCMNOTIFYEVENT_RESET) 1681 pThis->incrementCounterProp("/VirtualBox/VMInfo/ResetCounter"); 1682 } 1683 catch (std::bad_alloc &) 1684 { 1685 /* ignore */ 1686 } 1642 1687 } 1643 1688 … … 1692 1737 1693 1738 /* Sysprep execution by VBoxService (host is allowed to change these). */ 1694 uint64_t nsTimestamp = getCurrentTimestamp(); 1695 setPropertyInternal("/VirtualBox/HostGuest/SysprepExec", "", GUEST_PROP_F_TRANSIENT | GUEST_PROP_F_RDONLYGUEST, 1696 nsTimestamp, false /*fIsGuest*/); 1697 setPropertyInternal("/VirtualBox/HostGuest/SysprepArgs", "", GUEST_PROP_F_TRANSIENT | GUEST_PROP_F_RDONLYGUEST, 1698 nsTimestamp, false /*fIsGuest*/); 1739 uint64_t nsNow = getCurrentTimestamp(); 1740 setPropertyInternal("/VirtualBox/HostGuest/SysprepExec", "", GUEST_PROP_F_TRANSIENT | GUEST_PROP_F_RDONLYGUEST, nsNow); 1741 setPropertyInternal("/VirtualBox/HostGuest/SysprepArgs", "", GUEST_PROP_F_TRANSIENT | GUEST_PROP_F_RDONLYGUEST, nsNow); 1742 1743 /* Resume and reset counters. */ 1744 setPropertyInternal("/VirtualBox/VMInfo/ResumeCounter", "0", GUEST_PROP_F_TRANSIENT | GUEST_PROP_F_RDONLYGUEST, nsNow); 1745 setPropertyInternal("/VirtualBox/VMInfo/ResetCounter", "0", GUEST_PROP_F_TRANSIENT | GUEST_PROP_F_RDONLYGUEST, nsNow); 1699 1746 } 1700 1747 catch (std::bad_alloc &)
Note:
See TracChangeset
for help on using the changeset viewer.