VirtualBox

source: vbox/trunk/src/VBox/Additions/common/VBoxGuestLib/VBoxGuestR3LibMisc.cpp@ 32242

Last change on this file since 32242 was 30668, checked in by vboxsync, 15 years ago

Generate a session id for the VM that is changed every time the VM starts, resets or is restored.

  • Property svn:eol-style set to native
  • Property svn:keyword set to Id
  • Property svn:keywords set to Id
File size: 3.0 KB
Line 
1/* $Id: VBoxGuestR3LibMisc.cpp 30668 2010-07-06 14:26:53Z vboxsync $ */
2/** @file
3 * VBoxGuestR3Lib - Ring-3 Support Library for VirtualBox guest additions, Misc.
4 */
5
6/*
7 * Copyright (C) 2007-2010 Oracle Corporation
8 *
9 * This file is part of VirtualBox Open Source Edition (OSE), as
10 * available from http://www.virtualbox.org. This file is free software;
11 * you can redistribute it and/or modify it under the terms of the GNU
12 * General Public License (GPL) as published by the Free Software
13 * Foundation, in version 2 as it comes in the "COPYING" file of the
14 * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
15 * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
16 *
17 * The contents of this file may alternatively be used under the terms
18 * of the Common Development and Distribution License Version 1.0
19 * (CDDL) only, as it comes in the "COPYING.CDDL" file of the
20 * VirtualBox OSE distribution, in which case the provisions of the
21 * CDDL are applicable instead of those of the GPL.
22 *
23 * You may elect to license modified versions of this file under the
24 * terms and conditions of either the GPL or the CDDL or both.
25 */
26
27
28/*******************************************************************************
29* Header Files *
30*******************************************************************************/
31#include <VBox/log.h>
32#include "VBGLR3Internal.h"
33
34
35/**
36 * Change the IRQ filter mask.
37 *
38 * @returns IPRT status code.
39 * @param fOr The OR mask.
40 * @param fNo The NOT mask.
41 */
42VBGLR3DECL(int) VbglR3CtlFilterMask(uint32_t fOr, uint32_t fNot)
43{
44 VBoxGuestFilterMaskInfo Info;
45 Info.u32OrMask = fOr;
46 Info.u32NotMask = fNot;
47 return vbglR3DoIOCtl(VBOXGUEST_IOCTL_CTL_FILTER_MASK, &Info, sizeof(Info));
48}
49
50
51/**
52 * Report a change in the capabilities that we support to the host.
53 *
54 * @returns IPRT status code.
55 * @param fOr Capabilities which have been added.
56 * @param fNot Capabilities which have been removed.
57 *
58 * @todo Move to a different file.
59 */
60VBGLR3DECL(int) VbglR3SetGuestCaps(uint32_t fOr, uint32_t fNot)
61{
62 VMMDevReqGuestCapabilities2 Req;
63
64 vmmdevInitRequest(&Req.header, VMMDevReq_SetGuestCapabilities);
65 Req.u32OrMask = fOr;
66 Req.u32NotMask = fNot;
67 int rc = vbglR3GRPerform(&Req.header);
68#if defined(DEBUG)
69 if (RT_SUCCESS(rc))
70 LogRel(("Successfully changed guest capabilities: or mask 0x%x, not mask 0x%x.\n", fOr, fNot));
71 else
72 LogRel(("Failed to change guest capabilities: or mask 0x%x, not mask 0x%x. rc=%Rrc.\n", fOr, fNot, rc));
73#endif
74 return rc;
75}
76
77/**
78 * Query the session id of this VM; this is a unique id that gets changed for each VM start, reset or restore.
79 * Useful for detection a VM restore.
80 *
81 * @returns IPRT status code.
82 * pu64IdSession Session id (out)
83 *
84 */
85VBGLR3DECL(int) VbglR3GetSessionId(uint64_t *pu64IdSession)
86{
87 VMMDevReqSessionId Req;
88
89 vmmdevInitRequest(&Req.header, VMMDevReq_GetSessionId);
90 int rc = vbglR3GRPerform(&Req.header);
91 if (rc == VINF_SUCCESS)
92 *pu64IdSession = Req.idSession;
93
94 return rc;
95}
Note: See TracBrowser for help on using the repository browser.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette