summaryrefslogtreecommitdiff
path: root/src/VBox/Frontends/VBoxManage/VBoxManageGuestProp.cpp
diff options
context:
space:
mode:
authorLorry Tar Creator <lorry-tar-importer@baserock.org>2014-03-26 19:21:20 +0000
committer <>2014-05-08 15:03:54 +0000
commitfb123f93f9f5ce42c8e5785d2f8e0edaf951740e (patch)
treec2103d76aec5f1f10892cd1d3a38e24f665ae5db /src/VBox/Frontends/VBoxManage/VBoxManageGuestProp.cpp
parent58ed4748338f9466599adfc8a9171280ed99e23f (diff)
downloadVirtualBox-master.tar.gz
Imported from /home/lorry/working-area/delta_VirtualBox/VirtualBox-4.3.10.tar.bz2.HEADVirtualBox-4.3.10master
Diffstat (limited to 'src/VBox/Frontends/VBoxManage/VBoxManageGuestProp.cpp')
-rw-r--r--src/VBox/Frontends/VBoxManage/VBoxManageGuestProp.cpp60
1 files changed, 50 insertions, 10 deletions
diff --git a/src/VBox/Frontends/VBoxManage/VBoxManageGuestProp.cpp b/src/VBox/Frontends/VBoxManage/VBoxManageGuestProp.cpp
index d072a4ea..7d95bb57 100644
--- a/src/VBox/Frontends/VBoxManage/VBoxManageGuestProp.cpp
+++ b/src/VBox/Frontends/VBoxManage/VBoxManageGuestProp.cpp
@@ -4,7 +4,7 @@
*/
/*
- * Copyright (C) 2006-2010 Oracle Corporation
+ * Copyright (C) 2006-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;
@@ -28,9 +28,7 @@
#include <VBox/com/array.h>
#include <VBox/com/ErrorInfo.h>
#include <VBox/com/errorprint.h>
-
#include <VBox/com/VirtualBox.h>
-#include <VBox/com/EventQueue.h>
#include <VBox/log.h>
#include <iprt/asm.h>
@@ -55,19 +53,23 @@ using namespace com;
void usageGuestProperty(PRTSTREAM pStrm, const char *pcszSep1, const char *pcszSep2)
{
RTStrmPrintf(pStrm,
- "%s guestproperty %s get <vmname>|<uuid>\n"
+ "%s guestproperty %s get <uuid|vmname>\n"
" <property> [--verbose]\n"
"\n", pcszSep1, pcszSep2);
RTStrmPrintf(pStrm,
- "%s guestproperty %s set <vmname>|<uuid>\n"
+ "%s guestproperty %s set <uuid|vmname>\n"
" <property> [<value> [--flags <flags>]]\n"
"\n", pcszSep1, pcszSep2);
RTStrmPrintf(pStrm,
- "%s guestproperty %s enumerate <vmname>|<uuid>\n"
+ "%s guestproperty %s delete|unset <uuid|vmname>\n"
+ " <property>\n"
+ "\n", pcszSep1, pcszSep2);
+ RTStrmPrintf(pStrm,
+ "%s guestproperty %s enumerate <uuid|vmname>\n"
" [--patterns <patterns>]\n"
"\n", pcszSep1, pcszSep2);
RTStrmPrintf(pStrm,
- "%s guestproperty %s wait <vmname>|<uuid> <patterns>\n"
+ "%s guestproperty %s wait <uuid|vmname> <patterns>\n"
" [--timeout <msec>] [--fail-on-timeout]\n"
"\n", pcszSep1, pcszSep2);
}
@@ -158,9 +160,7 @@ static int handleSetGuestProperty(HandlerArg *a)
/* get the mutable session machine */
a->session->COMGETTER(Machine)(machine.asOutParam());
- if (!pszValue && !pszFlags)
- CHECK_ERROR(machine, DeleteGuestProperty(Bstr(pszName).raw()));
- else if (!pszFlags)
+ if (!pszFlags)
CHECK_ERROR(machine, SetGuestPropertyValue(Bstr(pszName).raw(),
Bstr(pszValue).raw()));
else
@@ -176,6 +176,44 @@ static int handleSetGuestProperty(HandlerArg *a)
return SUCCEEDED(rc) ? 0 : 1;
}
+static int handleDeleteGuestProperty(HandlerArg *a)
+{
+ HRESULT rc = S_OK;
+
+ /*
+ * Check the syntax. We can deduce the correct syntax from the number of
+ * arguments.
+ */
+ bool usageOK = true;
+ const char *pszName = NULL;
+ if (a->argc != 2)
+ usageOK = false;
+ if (!usageOK)
+ return errorSyntax(USAGE_GUESTPROPERTY, "Incorrect parameters");
+ /* This is always needed. */
+ pszName = a->argv[1];
+
+ ComPtr<IMachine> machine;
+ CHECK_ERROR(a->virtualBox, FindMachine(Bstr(a->argv[0]).raw(),
+ machine.asOutParam()));
+ if (machine)
+ {
+ /* open a session for the VM - new or existing */
+ CHECK_ERROR_RET(machine, LockMachine(a->session, LockType_Shared), 1);
+
+ /* get the mutable session machine */
+ a->session->COMGETTER(Machine)(machine.asOutParam());
+
+ CHECK_ERROR(machine, DeleteGuestProperty(Bstr(pszName).raw()));
+
+ if (SUCCEEDED(rc))
+ CHECK_ERROR(machine, SaveSettings());
+
+ a->session->UnlockMachine();
+ }
+ return SUCCEEDED(rc) ? 0 : 1;
+}
+
/**
* Enumerates the properties in the guest property store.
*
@@ -384,6 +422,8 @@ int handleGuestProperty(HandlerArg *a)
return handleGetGuestProperty(&arg);
if (strcmp(a->argv[0], "set") == 0)
return handleSetGuestProperty(&arg);
+ if (strcmp(a->argv[0], "delete") == 0 || strcmp(a->argv[0], "unset") == 0)
+ return handleDeleteGuestProperty(&arg);
if (strcmp(a->argv[0], "enumerate") == 0)
return handleEnumGuestProperty(&arg);
if (strcmp(a->argv[0], "wait") == 0)