diff options
4 files changed, 86 insertions, 3 deletions
diff --git a/include/VBox/VBoxGuestLib.h b/include/VBox/VBoxGuestLib.h index d8ce3a9b3cd..b8cb1e273d4 100644 --- a/include/VBox/VBoxGuestLib.h +++ b/include/VBox/VBoxGuestLib.h @@ -526,6 +526,7 @@ VBGLR3DECL(int) VbglR3GuestPropEnum(uint32_t u32ClientId, char const * const VBGLR3DECL(int) VbglR3GuestPropEnumNext(PVBGLR3GUESTPROPENUM pHandle, char const **ppszName, char const **ppszValue, uint64_t *pu64Timestamp, char const **ppszFlags); VBGLR3DECL(void) VbglR3GuestPropEnumFree(PVBGLR3GUESTPROPENUM pHandle); +VBGLR3DECL(int) VbglR3GuestPropDelete(uint32_t u32ClientId, const char *pszName); VBGLR3DECL(int) VbglR3GuestPropDelSet(uint32_t u32ClientId, char const * const *papszPatterns, uint32_t cPatterns); VBGLR3DECL(int) VbglR3GuestPropWait(uint32_t u32ClientId, const char *pszPatterns, void *pvBuf, uint32_t cbBuf, uint64_t u64Timestamp, uint32_t cMillies, char ** ppszName, char **ppszValue, uint64_t *pu64Timestamp, char **ppszFlags, uint32_t *pcbBufActual); /** @} */ diff --git a/src/VBox/Additions/common/VBoxControl/VBoxControl.cpp b/src/VBox/Additions/common/VBoxControl/VBoxControl.cpp index 6a8f2b0256b..1107de32428 100644 --- a/src/VBox/Additions/common/VBoxControl/VBoxControl.cpp +++ b/src/VBox/Additions/common/VBoxControl/VBoxControl.cpp @@ -4,7 +4,7 @@ */ /* - * Copyright (C) 2008-2010 Oracle Corporation + * Copyright (C) 2008-2013 Oracle Corporation * * This file is part of VirtualBox Open Source Edition (OSE), as * available from http://www.virtualbox.org. This file is free software; @@ -121,6 +121,7 @@ static void usage(enum VBoxControlUsage eWhich = USAGE_ALL) { doUsage("get <property> [--verbose]", g_pszProgName, "guestproperty"); doUsage("set <property> [<value> [--flags <flags>]]", g_pszProgName, "guestproperty"); + doUsage("delete <property>", g_pszProgName, "guestproperty"); doUsage("enumerate [--patterns <patterns>]", g_pszProgName, "guestproperty"); doUsage("wait <patterns>", g_pszProgName, "guestproperty"); doUsage("[--timestamp <last timestamp>]"); @@ -1092,6 +1093,51 @@ static RTEXITCODE setGuestProperty(int argc, char *argv[]) /** + * Deletes a guest property from the guest property store. + * This is accessed through the "VBoxGuestPropSvc" HGCM service. + * + * @returns Command exit code. + * @note see the command line API description for parameters + */ +static RTEXITCODE deleteGuestProperty(int argc, char *argv[]) +{ + /* + * Check the syntax. We can deduce the correct syntax from the number of + * arguments. + */ + bool usageOK = true; + const char *pszName = NULL; + if (argc < 1) + usageOK = false; + if (!usageOK) + { + usage(GUEST_PROP); + return RTEXITCODE_FAILURE; + } + /* This is always needed. */ + pszName = argv[0]; + + /* + * Do the actual setting. + */ + uint32_t u32ClientId = 0; + int rc = VbglR3GuestPropConnect(&u32ClientId); + if (!RT_SUCCESS(rc)) + VBoxControlError("Failed to connect to the guest property service, error %Rrc\n", rc); + if (RT_SUCCESS(rc)) + { + rc = VbglR3GuestPropDelete(u32ClientId, pszName); + if (!RT_SUCCESS(rc)) + VBoxControlError("Failed to delete the property value, error %Rrc\n", rc); + } + + if (u32ClientId != 0) + VbglR3GuestPropDisconnect(u32ClientId); + return RT_SUCCESS(rc) ? RTEXITCODE_SUCCESS : RTEXITCODE_FAILURE; +} + + +/** * Enumerates the properties in the guest property store. * This is accessed through the "VBoxGuestPropSvc" HGCM service. * @@ -1311,6 +1357,8 @@ static RTEXITCODE handleGuestProperty(int argc, char *argv[]) return getGuestProperty(argc - 1, argv + 1); else if (!strcmp(argv[0], "set")) return setGuestProperty(argc - 1, argv + 1); + else if (!strcmp(argv[0], "delete")) + return deleteGuestProperty(argc - 1, argv + 1); else if (!strcmp(argv[0], "enumerate")) return enumGuestProperty(argc - 1, argv + 1); else if (!strcmp(argv[0], "wait")) diff --git a/src/VBox/Additions/common/VBoxControl/testcase/tstVBoxControl.cpp b/src/VBox/Additions/common/VBoxControl/testcase/tstVBoxControl.cpp index 0368a0cb4d0..cd6e4146d5a 100644 --- a/src/VBox/Additions/common/VBoxControl/testcase/tstVBoxControl.cpp +++ b/src/VBox/Additions/common/VBoxControl/testcase/tstVBoxControl.cpp @@ -4,7 +4,7 @@ */ /* - * Copyright (C) 2007 Oracle Corporation + * Copyright (C) 2007-2013 Oracle Corporation * * This file is part of VirtualBox Open Source Edition (OSE), as * available from http://www.virtualbox.org. This file is free software; @@ -97,6 +97,14 @@ VBGLR3DECL(int) VbglR3GuestPropRead(uint32_t u32ClientId, return VINF_SUCCESS; } +VBGLR3DECL(int) VbglR3GuestPropDelete(uint32_t u32ClientId, + const char *pszName) +{ + RTPrintf("Called DEL_PROP, client %d, name %s...\n", + u32ClientId, pszName); + return VINF_SUCCESS; +} + struct VBGLR3GUESTPROPENUM { uint32_t u32; diff --git a/src/VBox/Additions/common/VBoxGuestLib/VBoxGuestR3LibGuestProp.cpp b/src/VBox/Additions/common/VBoxGuestLib/VBoxGuestR3LibGuestProp.cpp index 503f8ef8ef5..e1765aeadf9 100644 --- a/src/VBox/Additions/common/VBoxGuestLib/VBoxGuestR3LibGuestProp.cpp +++ b/src/VBox/Additions/common/VBoxGuestLib/VBoxGuestR3LibGuestProp.cpp @@ -4,7 +4,7 @@ */ /* - * Copyright (C) 2007 Oracle Corporation + * Copyright (C) 2007-2013 Oracle Corporation * * This file is part of VirtualBox Open Source Edition (OSE), as * available from http://www.virtualbox.org. This file is free software; @@ -783,6 +783,32 @@ VBGLR3DECL(void) VbglR3GuestPropEnumFree(PVBGLR3GUESTPROPENUM pHandle) /** + * Deletes a guest property. + * + * @returns VBox status code. + * @param u32ClientId The client id returned by VbglR3InvsSvcConnect(). + * @param pszName The property to delete. Utf8 + */ +VBGLR3DECL(int) VbglR3GuestPropDelete(uint32_t u32ClientId, const char *pszName) +{ + AssertPtrReturn(pszName, VERR_INVALID_POINTER); + + DelProperty Msg; + + Msg.hdr.result = VERR_WRONG_ORDER; + Msg.hdr.u32ClientID = u32ClientId; + Msg.hdr.u32Function = DEL_PROP; + Msg.hdr.cParms = 1; + VbglHGCMParmPtrSetString(&Msg.name, pszName); + int rc = vbglR3DoIOCtl(VBOXGUEST_IOCTL_HGCM_CALL(sizeof(Msg)), &Msg, sizeof(Msg)); + if (RT_SUCCESS(rc)) + rc = Msg.hdr.result; + + return rc; +} + + +/** * Deletes a set of keys. * * The set is specified in the same way as for VbglR3GuestPropEnum. |