Changeset 10826
- Timestamp:
- 07/23/08 12:08:59 (1 month ago)
- Files:
-
- trunk/src/VBox/Frontends/VBoxManage/VBoxManage.cpp (modified) (6 diffs)
- trunk/src/VBox/Frontends/VBoxManage/VBoxManage.h (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/src/VBox/Frontends/VBoxManage/VBoxManage.cpp
r10797 r10826 653 653 654 654 #ifdef VBOX_WITH_GUEST_PROPS 655 if (u64Cmd & USAGE_GETGUESTPROPERTY) 656 { 657 RTPrintf("VBoxManage getguestproperty <vmname>|<uuid> <key>\n" 655 if (u64Cmd & USAGE_GUESTPROPERTY) 656 { 657 RTPrintf("VBoxManage guestproperty get <vmname>|<uuid>\n" 658 " <property> [-verbose]\n" 658 659 "\n"); 659 } 660 661 if (u64Cmd & USAGE_SETGUESTPROPERTY) 662 { 663 RTPrintf("VBoxManage setguestproperty <vmname>|<uuid> <key>\n" 664 " [<value>] (no value deletes key)\n" 660 RTPrintf("VBoxManage guestproperty set <vmname>|<uuid>\n" 661 " <property> [<value>] [-flags <flags>]\n" 665 662 "\n"); 666 663 } … … 7598 7595 HRESULT rc = S_OK; 7599 7596 7600 if (argc != 2) 7601 return errorSyntax(USAGE_GETGUESTPROPERTY, "Incorrect number of parameters"); 7597 bool verbose = false; 7598 if ((3 == argc) && (0 == strcmp(argv[2], "-verbose"))) 7599 verbose = true; 7600 else if (argc != 2) 7601 return errorSyntax(USAGE_GUESTPROPERTY, "Incorrect parameters"); 7602 7602 7603 7603 ComPtr<IMachine> machine; … … 7612 7612 { 7613 7613 Bstr value; 7614 CHECK_ERROR(machine, GetGuestPropertyValue(Bstr(argv[1]), value.asOutParam())); 7614 uint64_t u64Timestamp; 7615 Bstr flags; 7616 CHECK_ERROR(machine, GetGuestProperty(Bstr(argv[1]), value.asOutParam(), 7617 &u64Timestamp, flags.asOutParam())); 7618 if (!value) 7619 RTPrintf("No value set!\n"); 7615 7620 if (value) 7616 7621 RTPrintf("Value: %lS\n", value.raw()); 7617 else 7618 RTPrintf("No value set!\n"); 7622 if (value && verbose) 7623 { 7624 RTPrintf("Timestamp: %lld\n", u64Timestamp); 7625 RTPrintf("Flags: %lS\n", flags.raw()); 7626 } 7619 7627 } 7620 7628 return SUCCEEDED(rc) ? 0 : 1; … … 7627 7635 HRESULT rc = S_OK; 7628 7636 7629 if (argc < 2) 7630 return errorSyntax(USAGE_SETGUESTPROPERTY, "Not enough parameters"); 7637 /* 7638 * Check the syntax. We can deduce the correct syntax from the number of 7639 * arguments. 7640 */ 7641 bool usageOK = true; 7642 const char *pszName = NULL; 7643 const char *pszValue = NULL; 7644 const char *pszFlags = NULL; 7645 if (3 == argc) 7646 { 7647 pszName = argv[1]; 7648 pszValue = argv[2]; 7649 } 7650 else if (4 == argc) 7651 { 7652 pszName = argv[1]; 7653 if (strcmp(argv[2], "-flags") != 0) 7654 usageOK = false; 7655 pszFlags = argv[3]; 7656 } 7657 else if (5 == argc) 7658 { 7659 pszName = argv[1]; 7660 pszValue = argv[2]; 7661 if (strcmp(argv[3], "-flags") != 0) 7662 usageOK = false; 7663 pszFlags = argv[4]; 7664 } 7665 else if (argc != 2) 7666 usageOK = false; 7667 if (!usageOK) 7668 return errorSyntax(USAGE_GUESTPROPERTY, "Incorrect parameters"); 7631 7669 7632 7670 ComPtr<IMachine> machine; … … 7640 7678 if (machine) 7641 7679 { 7642 if (argc < 3) 7643 CHECK_ERROR(machine, SetGuestPropertyValue(Bstr(argv[1]), NULL)); 7644 else if (argc == 3) 7645 CHECK_ERROR(machine, SetGuestPropertyValue(Bstr(argv[1]), Bstr(argv[2]))); 7680 if ((NULL == pszValue) && (NULL == pszFlags)) 7681 CHECK_ERROR(machine, SetGuestPropertyValue(Bstr(pszName), NULL)); 7682 else if (NULL == pszFlags) 7683 CHECK_ERROR(machine, SetGuestPropertyValue(Bstr(pszName), Bstr(pszValue))); 7684 else if (NULL == pszValue) 7685 CHECK_ERROR(machine, SetGuestProperty(Bstr(pszName), NULL, Bstr(pszFlags))); 7646 7686 else 7647 return errorSyntax(USAGE_SETGUESTPROPERTY, "Too many parameters");7687 CHECK_ERROR(machine, SetGuestProperty(Bstr(pszName), Bstr(pszValue), Bstr(pszFlags))); 7648 7688 } 7649 7689 return SUCCEEDED(rc) ? 0 : 1; 7650 7690 } 7691 7692 7693 /** 7694 * Access the guest property store. 7695 * 7696 * @returns 0 on success, 1 on failure 7697 * @note see the command line API description for parameters 7698 */ 7699 static int handleGuestProperty(int argc, char *argv[], 7700 ComPtr<IVirtualBox> aVirtualBox, ComPtr<ISession> aSession) 7701 { 7702 if (0 == argc) 7703 return errorSyntax(USAGE_GUESTPROPERTY, "Incorrect parameters"); 7704 if (0 == strcmp(argv[0], "get")) 7705 return handleGetGuestProperty(argc - 1, argv + 1, aVirtualBox, aSession); 7706 else if (0 == strcmp(argv[0], "set")) 7707 return handleSetGuestProperty(argc - 1, argv + 1, aVirtualBox, aSession); 7708 /* else */ 7709 return errorSyntax(USAGE_GUESTPROPERTY, "Incorrect parameters"); 7710 } 7711 7651 7712 #endif /* VBOX_WITH_GUEST_PROPS defined */ 7652 7713 … … 7986 8047 { "vmstatistics", handleVMStatistics }, 7987 8048 #ifdef VBOX_WITH_GUEST_PROPS 7988 { "getguestproperty", handleGetGuestProperty }, 7989 { "setguestproperty", handleSetGuestProperty }, 8049 { "guestproperty", handleGuestProperty }, 7990 8050 #endif /* VBOX_WITH_GUEST_PROPS defined */ 7991 8051 { NULL, NULL } trunk/src/VBox/Frontends/VBoxManage/VBoxManage.h
r10797 r10826 71 71 #define USAGE_RENAMEVMDK RT_BIT_64(39) 72 72 #ifdef VBOX_WITH_GUEST_PROPS 73 #define USAGE_GETGUESTPROPERTY RT_BIT_64(40) 74 #define USAGE_SETGUESTPROPERTY RT_BIT_64(41) 73 #define USAGE_GUESTPROPERTY RT_BIT_64(40) 75 74 #endif /* VBOX_WITH_GUEST_PROPS defined */ 76 75 #define USAGE_ALL (~(uint64_t)0)

