Changeset 25200 in vbox for trunk/src/VBox/Main
- Timestamp:
- Dec 4, 2009 6:19:05 PM (15 years ago)
- svn:sync-xref-src-repo-rev:
- 55681
- Location:
- trunk/src/VBox/Main
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Main/HostImpl.cpp
r25151 r25200 30 30 #endif // VBOX_WITH_USB 31 31 32 #include "MediumImpl.h" 32 33 #include "HostPower.h" 33 34 -
trunk/src/VBox/Main/MediumAttachmentImpl.cpp
r25149 r25200 22 22 #include "MediumAttachmentImpl.h" 23 23 #include "MachineImpl.h" 24 #include "MediumImpl.h" 24 25 #include "Global.h" 25 26 26 27 #include "Logging.h" 28 29 //////////////////////////////////////////////////////////////////////////////// 30 // 31 // private member data definition 32 // 33 //////////////////////////////////////////////////////////////////////////////// 34 35 struct BackupableMediumAttachmentData 36 { 37 BackupableMediumAttachmentData() 38 : lPort(0), 39 lDevice(0), 40 type(DeviceType_Null), 41 fPassthrough(false), 42 fImplicit(false) 43 { } 44 45 bool operator==(const BackupableMediumAttachmentData &that) const 46 { 47 return this == &that 48 || (fPassthrough == that.fPassthrough); 49 } 50 51 ComObjPtr<Medium> pMedium; 52 /* Since MediumAttachment is not a first class citizen when it 53 * comes to managing settings, having a reference to the storage 54 * controller will not work - when settings are changed it will point 55 * to the old, uninitialized instance. Changing this requires 56 * substantial changes to MediumImpl.cpp. */ 57 const Bstr bstrControllerName; 58 const LONG lPort; 59 const LONG lDevice; 60 const DeviceType_T type; 61 bool fPassthrough : 1; 62 bool fImplicit : 1; 63 }; 64 65 struct MediumAttachment::Data 66 { 67 Data() 68 { } 69 70 /** Reference to Machine object, for checking mutable state. */ 71 const ComObjPtr<Machine, ComWeakRef> pMachine; 72 /* later: const ComObjPtr<MediumAttachment> mPeer; */ 73 74 Backupable<BackupableMediumAttachmentData> bd; 75 }; 27 76 28 77 // constructor / destructor 29 78 ///////////////////////////////////////////////////////////////////////////// 30 31 DEFINE_EMPTY_CTOR_DTOR(MediumAttachment)32 79 33 80 HRESULT MediumAttachment::FinalConstruct() … … 75 122 AssertReturn(autoInitSpan.isOk(), E_FAIL); 76 123 77 unconst(mParent) = aParent; 78 79 m.allocate(); 80 m->medium = aMedium; 81 unconst(m->controllerName) = aControllerName; 82 unconst(m->port) = aPort; 83 unconst(m->device) = aDevice; 84 unconst(m->type) = aType; 85 unconst(m->passthrough) = false; 86 87 m->implicit = aImplicit; 124 m = new Data(); 125 126 unconst(m->pMachine) = aParent; 127 128 m->bd.allocate(); 129 m->bd->pMedium = aMedium; 130 unconst(m->bd->bstrControllerName) = aControllerName; 131 unconst(m->bd->lPort) = aPort; 132 unconst(m->bd->lDevice) = aDevice; 133 unconst(m->bd->type) = aType; 134 135 m->bd->fPassthrough = false; 136 m->bd->fImplicit = aImplicit; 88 137 89 138 /* Confirm a successful initialization when it's the case */ … … 116 165 return; 117 166 118 m.free(); 119 120 unconst(mParent).setNull(); 121 122 LogFlowThisFuncLeave(); 167 m->bd.free(); 168 169 unconst(m->pMachine).setNull(); 170 171 delete m; 172 m = NULL; 173 174 LogFlowThisFuncLeave(); 175 } 176 177 // IHardDiskAttachment properties 178 ///////////////////////////////////////////////////////////////////////////// 179 180 STDMETHODIMP MediumAttachment::COMGETTER(Medium)(IMedium **aHardDisk) 181 { 182 LogFlowThisFuncEnter(); 183 184 CheckComArgOutPointerValid(aHardDisk); 185 186 AutoCaller autoCaller(this); 187 if (FAILED(autoCaller.rc())) return autoCaller.rc(); 188 189 AutoReadLock alock(this); 190 191 m->bd->pMedium.queryInterfaceTo(aHardDisk); 192 193 LogFlowThisFuncLeave(); 194 return S_OK; 195 } 196 197 STDMETHODIMP MediumAttachment::COMGETTER(Controller)(BSTR *aController) 198 { 199 LogFlowThisFuncEnter(); 200 201 CheckComArgOutPointerValid(aController); 202 203 AutoCaller autoCaller(this); 204 if (FAILED(autoCaller.rc())) return autoCaller.rc(); 205 206 /* m->controller is constant during life time, no need to lock */ 207 m->bd->bstrControllerName.cloneTo(aController); 208 209 LogFlowThisFuncLeave(); 210 return S_OK; 211 } 212 213 STDMETHODIMP MediumAttachment::COMGETTER(Port)(LONG *aPort) 214 { 215 LogFlowThisFuncEnter(); 216 217 CheckComArgOutPointerValid(aPort); 218 219 AutoCaller autoCaller(this); 220 if (FAILED(autoCaller.rc())) return autoCaller.rc(); 221 222 /* m->bd->port is constant during life time, no need to lock */ 223 *aPort = m->bd->lPort; 224 225 LogFlowThisFuncLeave(); 226 return S_OK; 227 } 228 229 STDMETHODIMP MediumAttachment::COMGETTER(Device)(LONG *aDevice) 230 { 231 LogFlowThisFuncEnter(); 232 233 CheckComArgOutPointerValid(aDevice); 234 235 AutoCaller autoCaller(this); 236 if (FAILED(autoCaller.rc())) return autoCaller.rc(); 237 238 /* m->bd->device is constant during life time, no need to lock */ 239 *aDevice = m->bd->lDevice; 240 241 LogFlowThisFuncLeave(); 242 return S_OK; 243 } 244 245 STDMETHODIMP MediumAttachment::COMGETTER(Type)(DeviceType_T *aType) 246 { 247 LogFlowThisFuncEnter(); 248 249 CheckComArgOutPointerValid(aType); 250 251 AutoCaller autoCaller(this); 252 if (FAILED(autoCaller.rc())) return autoCaller.rc(); 253 254 /* m->bd->type is constant during life time, no need to lock */ 255 *aType = m->bd->type; 256 257 LogFlowThisFuncLeave(); 258 return S_OK; 259 } 260 261 STDMETHODIMP MediumAttachment::COMGETTER(Passthrough)(BOOL *aPassthrough) 262 { 263 LogFlowThisFuncEnter(); 264 265 CheckComArgOutPointerValid(aPassthrough); 266 267 AutoCaller autoCaller(this); 268 if (FAILED(autoCaller.rc())) return autoCaller.rc(); 269 270 AutoReadLock lock(this); 271 272 *aPassthrough = m->bd->fPassthrough; 273 274 LogFlowThisFuncLeave(); 275 return S_OK; 123 276 } 124 277 … … 138 291 bool changed = false; 139 292 140 if (m .isBackedUp())293 if (m->bd.isBackedUp()) 141 294 { 142 295 /* we need to check all data to see whether anything will be changed 143 296 * after rollback */ 144 changed = m .hasActualChanges();145 m .rollback();297 changed = m->bd.hasActualChanges(); 298 m->bd.rollback(); 146 299 } 147 300 … … 163 316 AutoWriteLock alock(this); 164 317 165 if (m.isBackedUp()) 166 m.commit(); 167 168 LogFlowThisFuncLeave(); 169 } 170 171 172 // IHardDiskAttachment properties 173 ///////////////////////////////////////////////////////////////////////////// 174 175 STDMETHODIMP MediumAttachment::COMGETTER(Medium)(IMedium **aHardDisk) 176 { 177 LogFlowThisFuncEnter(); 178 179 CheckComArgOutPointerValid(aHardDisk); 180 181 AutoCaller autoCaller(this); 182 if (FAILED(autoCaller.rc())) return autoCaller.rc(); 183 184 AutoReadLock alock(this); 185 186 m->medium.queryInterfaceTo(aHardDisk); 187 188 LogFlowThisFuncLeave(); 189 return S_OK; 190 } 191 192 STDMETHODIMP MediumAttachment::COMGETTER(Controller)(BSTR *aController) 193 { 194 LogFlowThisFuncEnter(); 195 196 CheckComArgOutPointerValid(aController); 197 198 AutoCaller autoCaller(this); 199 if (FAILED(autoCaller.rc())) return autoCaller.rc(); 200 201 /* m->controller is constant during life time, no need to lock */ 202 m->controllerName.cloneTo(aController); 203 204 LogFlowThisFuncLeave(); 205 return S_OK; 206 } 207 208 STDMETHODIMP MediumAttachment::COMGETTER(Port)(LONG *aPort) 209 { 210 LogFlowThisFuncEnter(); 211 212 CheckComArgOutPointerValid(aPort); 213 214 AutoCaller autoCaller(this); 215 if (FAILED(autoCaller.rc())) return autoCaller.rc(); 216 217 /* m->port is constant during life time, no need to lock */ 218 *aPort = m->port; 219 220 LogFlowThisFuncLeave(); 221 return S_OK; 222 } 223 224 STDMETHODIMP MediumAttachment::COMGETTER(Device)(LONG *aDevice) 225 { 226 LogFlowThisFuncEnter(); 227 228 CheckComArgOutPointerValid(aDevice); 229 230 AutoCaller autoCaller(this); 231 if (FAILED(autoCaller.rc())) return autoCaller.rc(); 232 233 /* m->device is constant during life time, no need to lock */ 234 *aDevice = m->device; 235 236 LogFlowThisFuncLeave(); 237 return S_OK; 238 } 239 240 STDMETHODIMP MediumAttachment::COMGETTER(Type)(DeviceType_T *aType) 241 { 242 LogFlowThisFuncEnter(); 243 244 CheckComArgOutPointerValid(aType); 245 246 AutoCaller autoCaller(this); 247 if (FAILED(autoCaller.rc())) return autoCaller.rc(); 248 249 /* m->type is constant during life time, no need to lock */ 250 *aType = m->type; 251 252 LogFlowThisFuncLeave(); 253 return S_OK; 254 } 255 256 STDMETHODIMP MediumAttachment::COMGETTER(Passthrough)(BOOL *aPassthrough) 257 { 258 LogFlowThisFuncEnter(); 259 260 CheckComArgOutPointerValid(aPassthrough); 261 262 AutoCaller autoCaller(this); 263 if (FAILED(autoCaller.rc())) return autoCaller.rc(); 264 318 if (m->bd.isBackedUp()) 319 m->bd.commit(); 320 321 LogFlowThisFuncLeave(); 322 } 323 324 bool MediumAttachment::isImplicit() const 325 { 326 return m->bd->fImplicit; 327 } 328 329 void MediumAttachment::setImplicit(bool aImplicit) 330 { 331 m->bd->fImplicit = aImplicit; 332 } 333 334 const ComObjPtr<Medium>& MediumAttachment::getMedium() const 335 { 336 return m->bd->pMedium; 337 } 338 339 Bstr MediumAttachment::getControllerName() const 340 { 341 return m->bd->bstrControllerName; 342 } 343 344 LONG MediumAttachment::getPort() const 345 { 346 return m->bd->lPort; 347 } 348 349 LONG MediumAttachment::getDevice() const 350 { 351 return m->bd->lDevice; 352 } 353 354 DeviceType_T MediumAttachment::getType() const 355 { 356 return m->bd->type; 357 } 358 359 bool MediumAttachment::getPassthrough() const 360 { 265 361 AutoReadLock lock(this); 266 267 *aPassthrough = m->passthrough; 268 269 LogFlowThisFuncLeave(); 270 return S_OK; 271 } 272 362 return m->bd->fPassthrough; 363 } 364 365 bool MediumAttachment::matches(CBSTR aControllerName, LONG aPort, LONG aDevice) 366 { 367 return ( aControllerName == m->bd->bstrControllerName 368 && aPort == m->bd->lPort 369 && aDevice == m->bd->lDevice); 370 } 371 372 /** Must be called from under this object's write lock. */ 373 void MediumAttachment::updateMedium(const ComObjPtr<Medium> &aMedium, bool aImplicit) 374 { 375 m->bd.backup(); 376 m->bd->pMedium = aMedium; 377 m->bd->fImplicit = aImplicit; 378 } 379 380 /** Must be called from under this object's write lock. */ 381 void MediumAttachment::updatePassthrough(bool aPassthrough) 382 { 383 m->bd.backup(); 384 m->bd->fPassthrough = aPassthrough; 385 } 386 -
trunk/src/VBox/Main/SnapshotImpl.cpp
r25194 r25200 23 23 24 24 #include "MachineImpl.h" 25 #include "MediumImpl.h" 25 26 #include "Global.h" 26 27 -
trunk/src/VBox/Main/include/MediumAttachmentImpl.h
r24989 r25200 25 25 #include "VirtualBoxBase.h" 26 26 27 #include "MediumImpl.h"28 29 27 class Machine; 30 28 class Medium; … … 48 46 END_COM_MAP() 49 47 50 DECLARE_EMPTY_CTOR_DTOR(MediumAttachment) 48 MediumAttachment() { }; 49 ~MediumAttachment() { }; 51 50 52 51 // public initializer/uninitializer for internal purposes only … … 63 62 void FinalRelease(); 64 63 65 bool rollback();66 void commit();67 68 64 // IMediumAttachment properties 69 65 STDMETHOD(COMGETTER(Medium))(IMedium **aMedium); … … 74 70 STDMETHOD(COMGETTER(Passthrough))(BOOL *aPassthrough); 75 71 76 // unsafe inline public methods for internal purposes only (ensure there is 72 // public internal methods 73 bool rollback(); 74 void commit(); 75 76 // unsafe public methods for internal purposes only (ensure there is 77 77 // a caller and a read lock before calling them!) 78 bool isImplicit() const; 79 void setImplicit(bool aImplicit); 78 80 79 bool isImplicit() const { return m->implicit; } 80 void setImplicit(bool aImplicit) { m->implicit = aImplicit; } 81 const ComObjPtr<Medium>& getMedium() const; 82 Bstr getControllerName() const; 83 LONG getPort() const; 84 LONG getDevice() const; 85 DeviceType_T getType() const; 86 bool getPassthrough() const; 81 87 82 const ComObjPtr<Medium>& getMedium() const { return m->medium; } 83 Bstr getControllerName() const { return m->controllerName; } 84 LONG getPort() const { return m->port; } 85 LONG getDevice() const { return m->device; } 86 DeviceType_T getType() const { return m->type; } 87 bool getPassthrough() const { AutoReadLock lock(this); return m->passthrough; } 88 89 bool matches(CBSTR aControllerName, LONG aPort, LONG aDevice) 90 { 91 return ( aControllerName == m->controllerName 92 && aPort == m->port 93 && aDevice == m->device); 94 } 88 bool matches(CBSTR aControllerName, LONG aPort, LONG aDevice); 95 89 96 90 /** Must be called from under this object's write lock. */ 97 void updateMedium(const ComObjPtr<Medium> &aMedium, bool aImplicit) 98 { 99 m.backup(); 100 m->medium = aMedium; 101 m->implicit = aImplicit; 102 } 91 void updateMedium(const ComObjPtr<Medium> &aMedium, bool aImplicit); 103 92 104 93 /** Must be called from under this object's write lock. */ 105 void updatePassthrough(bool aPassthrough) 106 { 107 m.backup(); 108 m->passthrough = aPassthrough; 109 } 94 void updatePassthrough(bool aPassthrough); 110 95 111 96 /** Get a unique and somewhat descriptive name for logging. */ … … 116 101 117 102 private: 118 119 /** Reference to Machine object, for checking mutable state. */ 120 const ComObjPtr<Machine, ComWeakRef> mParent; 121 /* later: const ComObjPtr<MediumAttachment> mPeer; */ 122 123 struct Data 124 { 125 Data() : port(0), device(0), type(DeviceType_Null), 126 passthrough(false), implicit(false) {} 127 128 bool operator== (const Data &that) const 129 { 130 return this == &that 131 || (passthrough == that.passthrough); 132 } 133 134 ComObjPtr<Medium> medium; 135 /* Since MediumAttachment is not a first class citizen when it 136 * comes to managing settings, having a reference to the storage 137 * controller will not work - when settings are changed it will point 138 * to the old, uninitialized instance. Changing this requires 139 * substantial changes to MediumImpl.cpp. */ 140 const Bstr controllerName; 141 const LONG port; 142 const LONG device; 143 const DeviceType_T type; 144 bool passthrough : 1; 145 bool implicit : 1; 146 }; 147 148 Backupable<Data> m; 103 struct Data; 104 Data *m; 149 105 150 106 Utf8Str mLogName; /**< For logging purposes */ -
trunk/src/VBox/Main/include/MediumImpl.h
r25152 r25200 25 25 26 26 #include "VirtualBoxBase.h" 27 28 #include <VBox/com/SupportErrorInfo.h>29 27 30 28 class VirtualBox; -
trunk/src/VBox/Main/include/VirtualBoxBase.h
r25152 r25200 29 29 30 30 #include "VBox/com/ErrorInfo.h" 31 #include <VBox/com/SupportErrorInfo.h> 31 32 32 33 #include "VBox/com/VirtualBox.h"
Note:
See TracChangeset
for help on using the changeset viewer.