Changeset 10797 in vbox for trunk/src/VBox/HostServices
- Timestamp:
- Jul 22, 2008 8:12:42 AM (17 years ago)
- Location:
- trunk/src/VBox/HostServices
- Files:
-
- 1 edited
- 3 copied
- 1 moved
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/HostServices/GuestProperties/Makefile.kmk
r10795 r10797 31 31 # The shared folder service DLL. 32 32 # 33 DLLS += VBox SharedInfoSvc34 VBox SharedInfoSvc_TEMPLATE = VBOXR335 VBox SharedInfoSvc_NAME.os2 = VBoxSIS36 VBox SharedInfoSvc_DEFS = VBOX_HGCM37 VBox SharedInfoSvc_INCS = $(PATH_ROOT)/src/VBox/Main/include38 VBox SharedInfoSvc_INCS.win = \33 DLLS += VBoxGuestPropSvc 34 VBoxGuestPropSvc_TEMPLATE = VBOXR3 35 VBoxGuestPropSvc_NAME.os2 = VBoxSIS 36 VBoxGuestPropSvc_DEFS = VBOX_HGCM 37 VBoxGuestPropSvc_INCS = $(PATH_ROOT)/src/VBox/Main/include 38 VBoxGuestPropSvc_INCS.win = \ 39 39 $(PATH_TOOL_$(VBOX_VCC_TOOL)_ATLMFC_INC) \ 40 40 $(VBOX_PATH_SDK) 41 41 42 VBox SharedInfoSvc_SOURCES = \42 VBoxGuestPropSvc_SOURCES = \ 43 43 service.cpp 44 44 45 VBox SharedInfoSvc_LIBS = \45 VBoxGuestPropSvc_LIBS = \ 46 46 $(LIB_VMM) \ 47 47 $(LIB_RUNTIME) \ -
trunk/src/VBox/HostServices/GuestProperties/noncopyable.h
r10795 r10797 20 20 */ 21 21 22 #ifndef ___ svcinfo_noncopyable_h23 # define ___ svcinfo_noncopyable_h22 #ifndef ___guestprop_noncopyable_h 23 # define ___guestprop_noncopyable_h 24 24 25 namespace svcInfo{25 namespace guestProp { 26 26 27 27 class noncopyable … … 35 35 }; 36 36 37 } /* namespace svcInfo*/37 } /* namespace guestProp */ 38 38 39 typedef svcInfo::noncopyable noncopyable;39 typedef guestProp::noncopyable noncopyable; 40 40 41 #endif /* ___ svcinfo_noncopyable_h not defined */41 #endif /* ___guestprop_noncopyable_h not defined */ -
trunk/src/VBox/HostServices/GuestProperties/service.cpp
r10795 r10797 1 1 /** @file 2 2 * 3 * Shared Information Services:3 * Guest Property Service: 4 4 * Host service entry points. 5 5 */ … … 22 22 23 23 /** 24 * An HGCM service for passing requests which do not need any persistant state 25 * to handle. We currently only support three types of request - set guest 26 * property (SET_CONFIG_KEY and SET_CONFIG_KEY_HOST), get guest property 27 * (GET_CONFIG_KEY and GET_CONFIG_KEY_HOST) and remove guest property 28 * (DEL_CONFIG_KEY and DEL_CONFIG_KEY_HOST). These may be used to read, to 29 * write and to remove configuration information which is available to 30 * both guest and host. This configuration information is stored in a CFGM 31 * node using the CFGM APIs. It is the responsibility of whoever creates the 32 * service to create this node and to tell the service about it using the 33 * SET_CFGM_NODE host call. It is also the responsibility of the service 34 * creator to save this information to disk and to retrieve it when needed. 35 * Since the CFGM APIs are single threaded, the creator must also ensure that 36 * no-one else accesses the configuration node while the service is running. 37 * 38 * If this service is extended to deal with new requests it would probably be a 39 * good idea to split it up into several files. 24 * This HGCM service allows the guest to set and query values in a property 25 * store on the host. The service proxies the guest requests to the service 26 * owner on the host using a request callback provided by the owner, and is 27 * notified of changes to properties made by the host. It forwards these 28 * notifications to clients in the guest which have expressed interest and 29 * are waiting for notification. 30 * 31 * The service currently consists of two threads. One of these is the main 32 * HGCM service thread which waits for requests from the guest and schedules 33 * these to the second thread. The second thread deals with the requests 34 * sequentially by calling the callback provided by the service owner, 35 * notifying the guest clients when it has finished dealing with a given 36 * request. 37 * 38 * Guest requests to wait for notification are dealt with differently. They 39 * are added to a list of open notification requests but do not schedule 40 * anything in the request thread except for a possible timeout. 40 41 */ 41 42 … … 45 46 * Header Files * 46 47 *******************************************************************************/ 47 #include <VBox/HostServices/ VBoxInfoSvc.h>48 #include <VBox/HostServices/GuestPropertySvc.h> 48 49 49 50 #include <memory> /* for auto_ptr */ … … 82 83 83 84 84 namespace svcInfo { 85 /** Set a uint64_t value to an HGCM parameter structure */ 86 static void VBoxHGCMParmUInt64Set (VBOXHGCMSVCPARM *pParm, uint64_t u64) 87 { 88 pParm->type = VBOX_HGCM_SVC_PARM_64BIT; 89 pParm->u.uint64 = u64; 90 } 91 92 93 namespace guestProp { 85 94 86 95 /** … … 158 167 int validateValue(char *pszValue, uint32_t cbValue); 159 168 int getKey(uint32_t cParms, VBOXHGCMSVCPARM paParms[]); 169 int getProperty(uint32_t cParms, VBOXHGCMSVCPARM paParms[]); 160 170 int setKey(uint32_t cParms, VBOXHGCMSVCPARM paParms[]); 161 171 int delKey(uint32_t cParms, VBOXHGCMSVCPARM paParms[]); … … 190 200 /* We want the byte length, not the Utf8 length */ 191 201 count = strlen(pszKey); 192 if (RT_SUCCESS(rc) && (count > KEY_MAX_LEN))202 if (RT_SUCCESS(rc) && (count > MAX_NAME_LEN)) 193 203 rc = VERR_INVALID_PARAMETER; 194 204 … … 220 230 /* We want the byte length, not the Utf8 length */ 221 231 count = strlen(pszValue); 222 if (RT_SUCCESS(rc) && (count > KEY_MAX_VALUE_LEN))232 if (RT_SUCCESS(rc) && (count > MAX_VALUE_LEN)) 223 233 rc = VERR_INVALID_PARAMETER; 224 234 … … 267 277 if (RT_SUCCESS(rc) && (cbValueActual > cbValue)) 268 278 rc = VERR_BUFFER_OVERFLOW; 269 if (RT_SUCCESS(rc) && (rc != VINF_BUFFER_OVERFLOW))279 if (RT_SUCCESS(rc)) 270 280 rc = CFGMR3QueryString(mpNode, pszKey, pszValue, cbValue); 271 if (RT_SUCCESS(rc) && (rc != VINF_BUFFER_OVERFLOW))281 if (RT_SUCCESS(rc)) 272 282 Log2(("Queried string %s, rc=%Rrc, value=%.*s\n", pszKey, rc, cbValue, pszValue)); 283 else if (VERR_CFGM_VALUE_NOT_FOUND == rc) 284 rc = VERR_NOT_FOUND; 285 LogFlowThisFunc(("rc = %Rrc\n", rc)); 286 return rc; 287 } 288 289 290 /** 291 * Retrieve a value from the guest registry by key, checking the validity 292 * of the arguments passed. If the guest has not allocated enough buffer 293 * space for the value then we return VERR_OVERFLOW and set the size of the 294 * buffer needed in the "size" HGCM parameter. If the key was not found at 295 * all, we return VERR_NOT_FOUND. 296 * 297 * @returns iprt status value 298 * @param cParms the number of HGCM parameters supplied 299 * @param paParms the array of HGCM parameters 300 * @thread HGCM 301 */ 302 int Service::getProperty(uint32_t cParms, VBOXHGCMSVCPARM paParms[]) 303 { 304 int rc = VINF_SUCCESS; 305 char *pszName, *pchBuf; 306 uint32_t cbName, cbBuf; 307 size_t cbValueActual; 308 309 LogFlowThisFunc(("\n")); 310 if ( (cParms != 4) /* Hardcoded value as the next lines depend on it. */ 311 || (paParms[0].type != VBOX_HGCM_SVC_PARM_PTR) /* name */ 312 || (paParms[1].type != VBOX_HGCM_SVC_PARM_PTR) /* buffer */ 313 ) 314 rc = VERR_INVALID_PARAMETER; 315 if (RT_SUCCESS(rc)) 316 rc = VBoxHGCMParmPtrGet(&paParms[0], (void **) &pszName, &cbName); 317 if (RT_SUCCESS(rc)) 318 rc = VBoxHGCMParmPtrGet(&paParms[1], (void **) &pchBuf, &cbBuf); 319 if (RT_SUCCESS(rc)) 320 rc = validateKey(pszName, cbName); 321 if (RT_SUCCESS(rc)) 322 rc = CFGMR3QuerySize(mpNode, pszName, &cbValueActual); 323 if (RT_SUCCESS(rc)) 324 { 325 /* Temporary hack for an empty flags string */ 326 cbValueActual += 1; 327 VBoxHGCMParmUInt32Set(&paParms[3], cbValueActual); 328 } 329 if (RT_SUCCESS(rc) && (cbValueActual > cbBuf)) 330 rc = VERR_BUFFER_OVERFLOW; 331 if (RT_SUCCESS(rc)) 332 rc = CFGMR3QueryString(mpNode, pszName, pchBuf, cbBuf); 333 if (RT_SUCCESS(rc)) 334 { 335 /* No timestamp */ 336 VBoxHGCMParmUInt64Set(&paParms[2], 0); 337 /* No flags */ 338 pchBuf[cbValueActual - 1] = 0; 339 } 340 if (RT_SUCCESS(rc)) 341 Log2(("Queried string %s, rc=%Rrc, value=%.*s\n", pszName, rc, cbBuf, pchBuf)); 273 342 else if (VERR_CFGM_VALUE_NOT_FOUND == rc) 274 343 rc = VERR_NOT_FOUND; … … 313 382 for (PCFGMNODE pChild = CFGMR3GetFirstChild(mpNode); pChild != 0; pChild = CFGMR3GetNextChild(pChild)) 314 383 ++cChildren; 315 if (cChildren >= KEY_MAX_KEYS)384 if (cChildren >= MAX_KEYS) 316 385 rc = VERR_TOO_MUCH_DATA; 317 386 } … … 381 450 switch (eFunction) 382 451 { 383 /* The guest wishes to read a configuration value */ 384 case GET_CONFIG_KEY: 385 LogFlowFunc(("GET_CONFIG_KEY\n")); 386 rc = getKey(cParms, paParms); 387 break; 388 389 /* The guest wishes to set a configuration value */ 390 case SET_CONFIG_KEY: 391 LogFlowFunc(("SET_CONFIG_KEY\n")); 452 /* The guest wishes to read a property */ 453 case GET_PROP: 454 LogFlowFunc(("GET_PROP\n")); 455 rc = getProperty(cParms, paParms); 456 break; 457 458 /* The guest wishes to set a property */ 459 case SET_PROP: 460 LogFlowFunc(("SET_PROP\n")); 461 rc = setKey(cParms - 1, paParms); 462 break; 463 464 /* The guest wishes to set a property value */ 465 case SET_PROP_VALUE: 466 LogFlowFunc(("SET_PROP_VALUE\n")); 392 467 rc = setKey(cParms, paParms); 393 468 break; 394 469 395 470 /* The guest wishes to remove a configuration value */ 396 case DEL_ CONFIG_KEY:397 LogFlowFunc(("DEL_ CONFIG_KEY\n"));471 case DEL_PROP: 472 LogFlowFunc(("DEL_PROP\n")); 398 473 rc = delKey(cParms, paParms); 399 474 break; … … 476 551 } 477 552 478 } /* namespace svcInfo*/479 480 using svcInfo::Service;553 } /* namespace guestProp */ 554 555 using guestProp::Service; 481 556 482 557 /** -
trunk/src/VBox/HostServices/Makefile.kmk
r10051 r10797 42 42 endif 43 43 endif 44 ifdef VBOX_WITH_ INFO_SVC45 include $(PATH_SUB_CURRENT)/ SharedInfoServices/Makefile.kmk44 ifdef VBOX_WITH_GUEST_PROPS 45 include $(PATH_SUB_CURRENT)/GuestProperties/Makefile.kmk 46 46 endif 47 47
Note:
See TracChangeset
for help on using the changeset viewer.