VirtualBox

source: vbox/trunk/src/VBox/Main/src-all/PCIDeviceAttachmentImpl.cpp@ 58959

Last change on this file since 58959 was 58959, checked in by vboxsync, 9 years ago

Main: Fix starting a VM with a physical PCI device attached. The assignment->COMGETTER(...) calls failed unnoticed with E_ACCESSDENIED producing bogues PCI addresses

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 3.7 KB
Line 
1/* $Id: PCIDeviceAttachmentImpl.cpp 58959 2015-12-02 21:10:52Z vboxsync $ */
2
3/** @file
4 *
5 * PCI attachment information implmentation.
6 */
7
8/*
9 * Copyright (C) 2010-2012 Oracle Corporation
10 *
11 * This file is part of VirtualBox Open Source Edition (OSE), as
12 * available from http://www.virtualbox.org. This file is free software;
13 * you can redistribute it and/or modify it under the terms of the GNU
14 * General Public License (GPL) as published by the Free Software
15 * Foundation, in version 2 as it comes in the "COPYING" file of the
16 * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
17 * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
18 */
19
20#include "PCIDeviceAttachmentImpl.h"
21#include "AutoCaller.h"
22#include "Global.h"
23#include "Logging.h"
24
25struct PCIDeviceAttachment::Data
26{
27 Data(const Bstr &aDevName,
28 LONG aHostAddress,
29 LONG aGuestAddress,
30 BOOL afPhysical)
31 : HostAddress(aHostAddress), GuestAddress(aGuestAddress),
32 fPhysical(afPhysical)
33 {
34 DevName = aDevName;
35 }
36
37 Bstr DevName;
38 LONG HostAddress;
39 LONG GuestAddress;
40 BOOL fPhysical;
41};
42
43// constructor / destructor
44/////////////////////////////////////////////////////////////////////////////
45DEFINE_EMPTY_CTOR_DTOR(PCIDeviceAttachment)
46
47HRESULT PCIDeviceAttachment::FinalConstruct()
48{
49 LogFlowThisFunc(("\n"));
50 return BaseFinalConstruct();
51}
52
53void PCIDeviceAttachment::FinalRelease()
54{
55 LogFlowThisFunc(("\n"));
56 uninit();
57 BaseFinalRelease();
58}
59
60// public initializer/uninitializer for internal purposes only
61/////////////////////////////////////////////////////////////////////////////
62HRESULT PCIDeviceAttachment::init(IMachine *aParent,
63 const Bstr &aDevName,
64 LONG aHostAddress,
65 LONG aGuestAddress,
66 BOOL fPhysical)
67{
68 NOREF(aParent);
69
70 /* Enclose the state transition NotReady->InInit->Ready */
71 AutoInitSpan autoInitSpan(this);
72 AssertReturn(autoInitSpan.isOk(), E_FAIL);
73
74 m = new Data(aDevName, aHostAddress, aGuestAddress, fPhysical);
75
76 /* Confirm a successful initialization */
77 autoInitSpan.setSucceeded();
78
79 return S_OK;
80}
81
82HRESULT PCIDeviceAttachment::i_loadSettings(IMachine *aParent,
83 const settings::HostPCIDeviceAttachment &hpda)
84{
85 Bstr bname(hpda.strDeviceName);
86 return init(aParent, bname, hpda.uHostAddress, hpda.uGuestAddress, TRUE);
87}
88
89
90HRESULT PCIDeviceAttachment::i_saveSettings(settings::HostPCIDeviceAttachment &data)
91{
92 Assert(m);
93 data.uHostAddress = m->HostAddress;
94 data.uGuestAddress = m->GuestAddress;
95 data.strDeviceName = m->DevName;
96
97 return S_OK;
98}
99
100/**
101 * Uninitializes the instance.
102 * Called from FinalRelease().
103 */
104void PCIDeviceAttachment::uninit()
105{
106 /* Enclose the state transition Ready->InUninit->NotReady */
107 AutoUninitSpan autoUninitSpan(this);
108 if (autoUninitSpan.uninitDone())
109 return;
110
111 delete m;
112 m = NULL;
113}
114
115// IPCIDeviceAttachment properties
116/////////////////////////////////////////////////////////////////////////////
117HRESULT PCIDeviceAttachment::getName(com::Utf8Str &aName)
118{
119 aName = m->DevName;
120 return S_OK;
121}
122
123HRESULT PCIDeviceAttachment::getIsPhysicalDevice(BOOL *aIsPhysicalDevice)
124{
125 *aIsPhysicalDevice = m->fPhysical;
126 return S_OK;
127}
128
129HRESULT PCIDeviceAttachment::getHostAddress(LONG *aHostAddress)
130{
131 *aHostAddress = m->HostAddress;
132 return S_OK;
133}
134HRESULT PCIDeviceAttachment::getGuestAddress(LONG *aGuestAddress)
135{
136 *aGuestAddress = m->GuestAddress;
137 return S_OK;
138}
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