VirtualBox

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

Last change on this file since 62772 was 61009, checked in by vboxsync, 8 years ago

Main: big settings cleanup and writing optimization. Moved constructors/equality/default checks into the .cpp file, and write only settings which aren't at the default value. Greatly reduces the effort needed to write everything out, especially when a lot of snapshots have to be dealt with. Move the storage controllers to the hardware settings, where they always belonged. No change to the XML file (yet). Lots of settings related cleanups in the API code.

  • 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 61009 2016-05-17 17:18:29Z vboxsync $ */
2
3/** @file
4 *
5 * PCI attachment information implmentation.
6 */
7
8/*
9 * Copyright (C) 2010-2016 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
25#include <VBox/settings.h>
26
27struct PCIDeviceAttachment::Data
28{
29 Data(const Utf8Str &aDevName,
30 LONG aHostAddress,
31 LONG aGuestAddress,
32 BOOL afPhysical)
33 : HostAddress(aHostAddress), GuestAddress(aGuestAddress),
34 fPhysical(afPhysical)
35 {
36 DevName = aDevName;
37 }
38
39 Utf8Str DevName;
40 LONG HostAddress;
41 LONG GuestAddress;
42 BOOL fPhysical;
43};
44
45// constructor / destructor
46/////////////////////////////////////////////////////////////////////////////
47DEFINE_EMPTY_CTOR_DTOR(PCIDeviceAttachment)
48
49HRESULT PCIDeviceAttachment::FinalConstruct()
50{
51 LogFlowThisFunc(("\n"));
52 return BaseFinalConstruct();
53}
54
55void PCIDeviceAttachment::FinalRelease()
56{
57 LogFlowThisFunc(("\n"));
58 uninit();
59 BaseFinalRelease();
60}
61
62// public initializer/uninitializer for internal purposes only
63/////////////////////////////////////////////////////////////////////////////
64HRESULT PCIDeviceAttachment::init(IMachine *aParent,
65 const Utf8Str &aDevName,
66 LONG aHostAddress,
67 LONG aGuestAddress,
68 BOOL fPhysical)
69{
70 NOREF(aParent);
71
72 /* Enclose the state transition NotReady->InInit->Ready */
73 AutoInitSpan autoInitSpan(this);
74 AssertReturn(autoInitSpan.isOk(), E_FAIL);
75
76 m = new Data(aDevName, aHostAddress, aGuestAddress, fPhysical);
77
78 /* Confirm a successful initialization */
79 autoInitSpan.setSucceeded();
80
81 return S_OK;
82}
83
84HRESULT PCIDeviceAttachment::i_loadSettings(IMachine *aParent,
85 const settings::HostPCIDeviceAttachment &hpda)
86{
87 return init(aParent, hpda.strDeviceName, hpda.uHostAddress, hpda.uGuestAddress, TRUE);
88}
89
90
91HRESULT PCIDeviceAttachment::i_saveSettings(settings::HostPCIDeviceAttachment &data)
92{
93 Assert(m);
94 data.uHostAddress = m->HostAddress;
95 data.uGuestAddress = m->GuestAddress;
96 data.strDeviceName = m->DevName;
97
98 return S_OK;
99}
100
101/**
102 * Uninitializes the instance.
103 * Called from FinalRelease().
104 */
105void PCIDeviceAttachment::uninit()
106{
107 /* Enclose the state transition Ready->InUninit->NotReady */
108 AutoUninitSpan autoUninitSpan(this);
109 if (autoUninitSpan.uninitDone())
110 return;
111
112 delete m;
113 m = NULL;
114}
115
116// IPCIDeviceAttachment properties
117/////////////////////////////////////////////////////////////////////////////
118HRESULT PCIDeviceAttachment::getName(com::Utf8Str &aName)
119{
120 aName = m->DevName;
121 return S_OK;
122}
123
124HRESULT PCIDeviceAttachment::getIsPhysicalDevice(BOOL *aIsPhysicalDevice)
125{
126 *aIsPhysicalDevice = m->fPhysical;
127 return S_OK;
128}
129
130HRESULT PCIDeviceAttachment::getHostAddress(LONG *aHostAddress)
131{
132 *aHostAddress = m->HostAddress;
133 return S_OK;
134}
135HRESULT PCIDeviceAttachment::getGuestAddress(LONG *aGuestAddress)
136{
137 *aGuestAddress = m->GuestAddress;
138 return S_OK;
139}
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