Changeset 36178 in vbox
- Timestamp:
- Mar 7, 2011 9:45:24 AM (14 years ago)
- svn:sync-xref-src-repo-rev:
- 70380
- Location:
- trunk
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/include/VBox/HostServices/GuestPropertySvc.h
r33540 r36178 59 59 enum ePropFlags 60 60 { 61 NILFLAG = 0, 62 TRANSIENT = RT_BIT(1), 63 RDONLYGUEST = RT_BIT(2), 64 RDONLYHOST = RT_BIT(3), 65 READONLY = RDONLYGUEST | RDONLYHOST, 66 ALLFLAGS = TRANSIENT | READONLY 61 NILFLAG = 0, 62 TRANSIENT = RT_BIT(1), 63 RDONLYGUEST = RT_BIT(2), 64 RDONLYHOST = RT_BIT(3), 65 /** Transient until VM gets a reset / restarts. */ 66 TRANSIENT_RESET = RT_BIT(4), 67 READONLY = RDONLYGUEST | RDONLYHOST, 68 ALLFLAGS = TRANSIENT | READONLY | TRANSIENT_RESET 67 69 }; 68 70 … … 75 77 DECLINLINE(const char *) flagName(uint32_t fFlag) 76 78 { 77 switch (fFlag)79 switch (fFlag) 78 80 { 79 81 case TRANSIENT: … … 85 87 case READONLY: 86 88 return "READONLY"; 89 case TRANSIENT_RESET: 90 return "TRANSIENT_RESET"; 87 91 default: 88 return NULL;92 break; 89 93 } 94 return NULL; 90 95 } 91 96 … … 106 111 * RDONLYGUEST, RDONLYHOST and RDONLY 107 112 */ 108 enum { MAX_FLAGS_LEN = sizeof("TRANSIENT , RDONLYGUEST") };113 enum { MAX_FLAGS_LEN = sizeof("TRANSIENT_RESET, RDONLYGUEST") }; 109 114 110 115 /** … … 123 128 static const uint32_t s_aFlagList[] = 124 129 { 125 TRANSIENT, READONLY, RDONLYGUEST, RDONLYHOST 130 /* 131 * Note: TRANSIENT_RESET must come before TRANSIENT because 132 * otherwise the RTStrNICmp with the flagNameLen parameter would 133 * fail below. 134 */ 135 TRANSIENT_RESET, TRANSIENT, READONLY, RDONLYGUEST, RDONLYHOST 126 136 }; 127 137 const char *pcszNext = pcszFlags; … … 138 148 unsigned i = 0; 139 149 for (; i < RT_ELEMENTS(s_aFlagList); ++i) 150 { 140 151 if (RTStrNICmp(pcszNext, flagName(s_aFlagList[i]), 141 152 flagNameLen(s_aFlagList[i])) == 0) 142 153 break; 154 } 143 155 if (RT_ELEMENTS(s_aFlagList) == i) 144 156 rc = VERR_PARSE_ERROR; … … 174 186 static const uint32_t s_aFlagList[] = 175 187 { 176 TRANSIENT , READONLY, RDONLYGUEST, RDONLYHOST188 TRANSIENT_RESET, TRANSIENT, READONLY, RDONLYGUEST, RDONLYHOST 177 189 }; 178 190 char *pszNext = pszFlags; -
trunk/src/VBox/Additions/common/VBoxService/VBoxServicePropCache.cpp
r34406 r36178 105 105 * gets deleted when the property cache did not have the chance to 106 106 * gracefully clean it up (due to a hard VM reset etc), so set this 107 * guest property using the TRANSIENT flag.107 * guest property using the TRANSIENT and TRANSIENT_RESET flags. 108 108 */ 109 rc = VbglR3GuestPropWrite(u32ClientId, pszName, pszValue, "TRANSIENT"); 109 rc = VbglR3GuestPropWrite(u32ClientId, pszName, pszValue, "TRANSIENT,TRANSIENT_RESET"); 110 if (rc == VERR_PARSE_ERROR) 111 { 112 /* Host does not support the "TRANSIENT_RESET" flag, so only 113 * use the "TRANSIENT" flag* -- better than nothing :-). */ 114 rc = VbglR3GuestPropWrite(u32ClientId, pszName, pszValue, "TRANSIENT"); 115 } 110 116 } 111 117 else … … 377 383 /* 378 384 * When destroying the cache and we have a temporary value, remove the 379 * (eventually) set TRANSIENT flag from it so that it doesn't get deleted385 * (eventually) set TRANSIENT_RESET flag from it so that it doesn't get deleted 380 386 * by the host side in order to put the actual reset value in it. 381 387 */ -
trunk/src/VBox/Additions/common/VBoxService/VBoxServicePropCache.h
r31925 r36178 21 21 #include "VBoxServiceInternal.h" 22 22 23 # ifdef VBOX_WITH_GUEST_PROPS23 # ifdef VBOX_WITH_GUEST_PROPS 24 24 25 /** Indicates wheter a guest property is temporary and either should 26 * get deleted when 27 * - a) the property cache gets destroyed, or 28 * - b) the VM gets a hard reset / shutdown 29 * or gets a default "reset" value (if specified via VBoxServicePropCacheUpdateEntry) 30 * when the property cache gets properly destroyed. 31 */ 25 32 #define VBOXSERVICEPROPCACHEFLAG_TEMPORARY RT_BIT(1) 33 /** Indicates whether a property every time needs to be updated, regardless 34 * if its real value changed or not. */ 26 35 #define VBOXSERVICEPROPCACHEFLAG_ALWAYS_UPDATE RT_BIT(2) 27 36 … … 32 41 int VBoxServicePropCacheFlush(PVBOXSERVICEVEPROPCACHE pCache); 33 42 void VBoxServicePropCacheDestroy(PVBOXSERVICEVEPROPCACHE pCache); 34 # endif43 # endif /* VBOX_WITH_GUEST_PROPS */ 35 44 36 #endif 45 #endif /* ___VBoxServicePropCache_h */ 37 46 -
trunk/src/VBox/Main/include/ConsoleImpl.h
r36041 r36178 619 619 ComSafeArrayOut(BSTR, aFlags)); 620 620 621 bool enabledGuestPropertiesVRDP(void); 622 void updateGuestPropertiesVRDPLogon(uint32_t u32ClientId, const char *pszUser, const char *pszDomain); 623 void updateGuestPropertiesVRDPDisconnect(uint32_t u32ClientId); 621 void guestPropertiesHandleVMReset(void); 622 bool guestPropertiesVRDPEnabled(void); 623 void guestPropertiesVRDPUpdateLogon(uint32_t u32ClientId, const char *pszUser, const char *pszDomain); 624 void guestPropertiesVRDPUpdateDisconnect(uint32_t u32ClientId); 624 625 #endif 625 626 -
trunk/src/VBox/Main/src-client/ConsoleImpl.cpp
r36074 r36178 673 673 #ifdef VBOX_WITH_GUEST_PROPS 674 674 675 bool Console::enabledGuestPropertiesVRDP(void) 675 /** 676 * Handles guest properties on a VM reset. 677 * At the moment we only delete properties which have the flag 678 * "TRARESET". 679 */ 680 void Console::guestPropertiesHandleVMReset(void) 681 { 682 com::SafeArray<BSTR> arrNames; 683 com::SafeArray<BSTR> arrValues; 684 com::SafeArray<LONG64> arrTimestamps; 685 com::SafeArray<BSTR> arrFlags; 686 HRESULT hrc = enumerateGuestProperties(Bstr("*").raw(), 687 ComSafeArrayAsOutParam(arrNames), 688 ComSafeArrayAsOutParam(arrValues), 689 ComSafeArrayAsOutParam(arrTimestamps), 690 ComSafeArrayAsOutParam(arrFlags)); 691 if (SUCCEEDED(hrc)) 692 { 693 for (size_t i = 0; i < arrFlags.size(); i++) 694 { 695 /* Delete all properties which have the flag "TRARESET". */ 696 if (Utf8Str(arrFlags[i]).contains("TRANSIENT_RESET", Utf8Str::CaseInsensitive)) 697 { 698 hrc = mMachine->SetGuestProperty(arrNames[i], Bstr("").raw() /* Value */, 699 Bstr("").raw() /* Flags */); 700 if (FAILED(hrc)) 701 LogRel(("RESET: Could not delete transient property \"%ls\", rc=%Rhrc\n", 702 arrNames[i], hrc)); 703 } 704 } 705 } 706 else 707 LogRel(("RESET: Unable to enumerate guest properties, rc=%Rhrc\n", hrc)); 708 } 709 710 bool Console::guestPropertiesVRDPEnabled(void) 676 711 { 677 712 Bstr value; 678 713 HRESULT hrc = mMachine->GetExtraData(Bstr("VBoxInternal2/EnableGuestPropertiesVRDP").raw(), 679 714 value.asOutParam()); 680 if (hrc == S_OK) 681 { 682 if (value == "1") 683 { 684 return true; 685 } 686 } 715 if ( hrc == S_OK 716 && value == "1") 717 return true; 687 718 return false; 688 719 } 689 720 690 void Console::updateGuestPropertiesVRDPLogon(uint32_t u32ClientId, const char *pszUser, const char *pszDomain) 691 { 692 if (!enabledGuestPropertiesVRDP()) 693 { 721 void Console::guestPropertiesVRDPUpdateLogon(uint32_t u32ClientId, const char *pszUser, const char *pszDomain) 722 { 723 if (!guestPropertiesVRDPEnabled()) 694 724 return; 695 }696 725 697 726 char szPropNm[256]; … … 725 754 } 726 755 727 void Console:: updateGuestPropertiesVRDPDisconnect(uint32_t u32ClientId)728 { 729 if (! enabledGuestPropertiesVRDP())756 void Console::guestPropertiesVRDPUpdateDisconnect(uint32_t u32ClientId) 757 { 758 if (!guestPropertiesVRDPEnabled()) 730 759 return; 731 760 … … 961 990 962 991 #ifdef VBOX_WITH_GUEST_PROPS 963 updateGuestPropertiesVRDPLogon(u32ClientId, pszUser, pszDomain);992 guestPropertiesVRDPUpdateLogon(u32ClientId, pszUser, pszDomain); 964 993 #endif /* VBOX_WITH_GUEST_PROPS */ 965 994 … … 1096 1125 1097 1126 #ifdef VBOX_WITH_GUEST_PROPS 1098 updateGuestPropertiesVRDPDisconnect(u32ClientId);1127 guestPropertiesVRDPUpdateDisconnect(u32ClientId); 1099 1128 #endif /* VBOX_WITH_GUEST_PROPS */ 1100 1129 … … 6768 6797 break; 6769 6798 } 6799 break; 6800 } 6801 6802 case VMSTATE_RESETTING: 6803 { 6804 #ifdef VBOX_WITH_GUEST_PROPS 6805 /* Do not take any read/write locks here! */ 6806 that->guestPropertiesHandleVMReset(); 6807 #endif 6770 6808 break; 6771 6809 } -
trunk/src/VBox/Main/src-server/MachineImpl.cpp
r36168 r36178 5009 5009 /** @todo Fix when adding DeleteGuestProperty(), 5010 5010 see defect. */ 5011 *aValue ? aValue : NULL, aFlags, true /* isSetter */, 5011 *aValue ? aValue : NULL, *aFlags ? aFlags : NULL, 5012 true /* isSetter */, 5012 5013 &dummy, &dummy64, &dummy); 5013 5014 } … … 8652 8653 || mData->mMachineState == MachineState_Aborted 8653 8654 || mData->mMachineState == MachineState_Teleported) 8654 && property.mFlags & guestProp::TRANSIENT) 8655 && ( property.mFlags & guestProp::TRANSIENT 8656 || property.mFlags & guestProp::TRANSIENT_RESET)) 8655 8657 continue; 8656 8658 settings::GuestProperty prop; … … 12217 12219 for (it = mHWData->mGuestProperties.begin(); 12218 12220 it != mHWData->mGuestProperties.end(); ++it) 12219 if (it->mFlags & guestProp::TRANSIENT) 12221 if ( (it->mFlags & guestProp::TRANSIENT) 12222 || (it->mFlags & guestProp::TRANSIENT_RESET)) 12220 12223 { 12221 12224 fNeedsSaving = true;
Note:
See TracChangeset
for help on using the changeset viewer.