Changeset 28162 in vbox for trunk/src/VBox/Main/ApplianceImpl.cpp
- Timestamp:
- Apr 11, 2010 12:44:21 PM (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Main/ApplianceImpl.cpp
r27918 r28162 628 628 } 629 629 630 void Appliance::disksWeight(uint32_t &ulTotalMB, uint32_t &cDisks) const 631 { 632 ulTotalMB = 0; 633 cDisks = 0; 634 /* Weigh the disk images according to their sizes */ 630 /** 631 * Refreshes the cDisks and ulTotalDisksMB members in the instance data. 632 * Requires that virtual system descriptions are present. 633 */ 634 void Appliance::disksWeight() 635 { 636 m->ulTotalDisksMB = 0; 637 m->cDisks = 0; 638 // weigh the disk images according to their sizes 635 639 list< ComObjPtr<VirtualSystemDescription> >::const_iterator it; 636 640 for (it = m->virtualSystemDescriptions.begin(); … … 647 651 { 648 652 const VirtualSystemDescriptionEntry *pHD = *itH; 649 ulTotalMB += pHD->ulSizeMB;650 ++ cDisks;653 m->ulTotalDisksMB += pHD->ulSizeMB; 654 ++m->cDisks; 651 655 } 652 656 } … … 654 658 } 655 659 656 HRESULT Appliance::setUpProgressFS(ComObjPtr<Progress> &pProgress, const Bstr &bstrDescription) 660 HRESULT Appliance::setUpProgress(ComObjPtr<Progress> &pProgress, 661 const Bstr &bstrDescription, 662 SetUpProgressMode mode) 657 663 { 658 664 HRESULT rc; … … 661 667 pProgress.createObject(); 662 668 663 /* Weigh the disk images according to their sizes */ 664 uint32_t ulTotalMB; 665 uint32_t cDisks; 666 disksWeight(ulTotalMB, cDisks); 667 668 ULONG cOperations = 1 + cDisks; // one op per disk plus 1 for the XML 669 669 // compute the disks weight (this sets ulTotalDisksMB and cDisks in the instance data) 670 disksWeight(); 671 672 ULONG cOperations; 670 673 ULONG ulTotalOperationsWeight; 671 if (ulTotalMB) 672 { 673 m->ulWeightPerOperation = (ULONG)((double)ulTotalMB * 1 / 100); // use 1% of the progress for the XML 674 ulTotalOperationsWeight = ulTotalMB + m->ulWeightPerOperation; 674 675 cOperations = 1 // one for XML setup 676 + m->cDisks; // plus one per disk 677 if (m->ulTotalDisksMB) 678 { 679 m->ulWeightPerOperation = (ULONG)((double)m->ulTotalDisksMB * 1 / 100); // use 1% of the progress for the XML 680 ulTotalOperationsWeight = m->ulTotalDisksMB + m->ulWeightPerOperation; 675 681 } 676 682 else 677 683 { 678 684 // no disks to export: 685 m->ulWeightPerOperation = 1; 679 686 ulTotalOperationsWeight = 1; 680 m->ulWeightPerOperation = 1; 687 } 688 689 switch (mode) 690 { 691 case Regular: 692 break; 693 694 case ImportS3: 695 { 696 cOperations += 1 + 1; // another one for the manifest file & another one for the import 697 ulTotalOperationsWeight = m->ulTotalDisksMB; 698 if (!m->ulTotalDisksMB) 699 // no disks to export: 700 ulTotalOperationsWeight = 1; 701 702 ULONG ulImportWeight = (ULONG)((double)ulTotalOperationsWeight * 50 / 100); // use 50% for import 703 ulTotalOperationsWeight += ulImportWeight; 704 705 m->ulWeightPerOperation = ulImportWeight; /* save for using later */ 706 707 ULONG ulInitWeight = (ULONG)((double)ulTotalOperationsWeight * 0.1 / 100); // use 0.1% for init 708 ulTotalOperationsWeight += ulInitWeight; 709 } 710 break; 711 712 case WriteS3: 713 { 714 cOperations += 1 + 1; // another one for the mf & another one for temporary creation 715 716 if (m->ulTotalDisksMB) 717 { 718 m->ulWeightPerOperation = (ULONG)((double)m->ulTotalDisksMB * 1 / 100); // use 1% of the progress for OVF file upload (we didn't know the size at this point) 719 ulTotalOperationsWeight = m->ulTotalDisksMB + m->ulWeightPerOperation; 720 } 721 else 722 { 723 // no disks to export: 724 ulTotalOperationsWeight = 1; 725 m->ulWeightPerOperation = 1; 726 } 727 ULONG ulOVFCreationWeight = (ULONG)((double)ulTotalOperationsWeight * 50.0 / 100.0); /* Use 50% for the creation of the OVF & the disks */ 728 ulTotalOperationsWeight += ulOVFCreationWeight; 729 } 730 break; 681 731 } 682 732 683 733 Log(("Setting up progress object: ulTotalMB = %d, cDisks = %d, => cOperations = %d, ulTotalOperationsWeight = %d, m->ulWeightPerOperation = %d\n", 684 ulTotalMB,cDisks, cOperations, ulTotalOperationsWeight, m->ulWeightPerOperation));734 m->ulTotalDisksMB, m->cDisks, cOperations, ulTotalOperationsWeight, m->ulWeightPerOperation)); 685 735 686 736 rc = pProgress->init(mVirtualBox, static_cast<IAppliance*>(this), … … 691 741 bstrDescription, // CBSTR bstrFirstOperationDescription, 692 742 m->ulWeightPerOperation); // ULONG ulFirstOperationWeight, 693 return rc;694 }695 696 HRESULT Appliance::setUpProgressImportS3(ComObjPtr<Progress> &pProgress, const Bstr &bstrDescription)697 {698 HRESULT rc;699 700 /* Create the progress object */701 pProgress.createObject();702 703 /* Weigh the disk images according to their sizes */704 uint32_t ulTotalMB;705 uint32_t cDisks;706 disksWeight(ulTotalMB, cDisks);707 708 ULONG cOperations = 1 + 1 + 1 + cDisks; // one op per disk plus 1 for init, plus 1 for the manifest file & 1 plus for the import */709 710 ULONG ulTotalOperationsWeight = ulTotalMB;711 if (!ulTotalOperationsWeight)712 // no disks to export:713 ulTotalOperationsWeight = 1;714 715 ULONG ulImportWeight = (ULONG)((double)ulTotalOperationsWeight * 50 / 100); // use 50% for import716 ulTotalOperationsWeight += ulImportWeight;717 718 m->ulWeightPerOperation = ulImportWeight; /* save for using later */719 720 ULONG ulInitWeight = (ULONG)((double)ulTotalOperationsWeight * 0.1 / 100); // use 0.1% for init721 ulTotalOperationsWeight += ulInitWeight;722 723 Log(("Setting up progress object: ulTotalMB = %d, cDisks = %d, => cOperations = %d, ulTotalOperationsWeight = %d, m->ulWeightPerOperation = %d\n",724 ulTotalMB, cDisks, cOperations, ulTotalOperationsWeight, m->ulWeightPerOperation));725 726 rc = pProgress->init(mVirtualBox, static_cast<IAppliance*>(this),727 bstrDescription,728 TRUE /* aCancelable */,729 cOperations, // ULONG cOperations,730 ulTotalOperationsWeight, // ULONG ulTotalOperationsWeight,731 Bstr(tr("Init")), // CBSTR bstrFirstOperationDescription,732 ulInitWeight); // ULONG ulFirstOperationWeight,733 return rc;734 }735 736 HRESULT Appliance::setUpProgressWriteS3(ComObjPtr<Progress> &pProgress, const Bstr &bstrDescription)737 {738 HRESULT rc;739 740 /* Create the progress object */741 pProgress.createObject();742 743 /* Weigh the disk images according to their sizes */744 uint32_t ulTotalMB;745 uint32_t cDisks;746 disksWeight(ulTotalMB, cDisks);747 748 ULONG cOperations = 1 + 1 + 1 + cDisks; // one op per disk plus 1 for the OVF, plus 1 for the mf & 1 plus to the temporary creation */749 750 ULONG ulTotalOperationsWeight;751 if (ulTotalMB)752 {753 m->ulWeightPerOperation = (ULONG)((double)ulTotalMB * 1 / 100); // use 1% of the progress for OVF file upload (we didn't know the size at this point)754 ulTotalOperationsWeight = ulTotalMB + m->ulWeightPerOperation;755 }756 else757 {758 // no disks to export:759 ulTotalOperationsWeight = 1;760 m->ulWeightPerOperation = 1;761 }762 ULONG ulOVFCreationWeight = (ULONG)((double)ulTotalOperationsWeight * 50.0 / 100.0); /* Use 50% for the creation of the OVF & the disks */763 ulTotalOperationsWeight += ulOVFCreationWeight;764 765 Log(("Setting up progress object: ulTotalMB = %d, cDisks = %d, => cOperations = %d, ulTotalOperationsWeight = %d, m->ulWeightPerOperation = %d\n",766 ulTotalMB, cDisks, cOperations, ulTotalOperationsWeight, m->ulWeightPerOperation));767 768 rc = pProgress->init(mVirtualBox, static_cast<IAppliance*>(this),769 bstrDescription,770 TRUE /* aCancelable */,771 cOperations, // ULONG cOperations,772 ulTotalOperationsWeight, // ULONG ulTotalOperationsWeight,773 bstrDescription, // CBSTR bstrFirstOperationDescription,774 ulOVFCreationWeight); // ULONG ulFirstOperationWeight,775 743 return rc; 776 744 }
Note:
See TracChangeset
for help on using the changeset viewer.