A kind of method and apparatus for conversion operations system running environment
Technical field
The present invention relates to virtual machine technique, particularly a kind of method and apparatus for conversion operations system running environment.
Background technology
Along with the development of ic manufacturing technology, the processing power of CPU (central processing unit) (CPU) is in continuous enhancing.Moore's Law shows: when price is constant, open ended transistor size on integrated circuit, about just can double every 18 months, and performance is also by lifting one times.And in most cases, application can not along with hardware synchronization improving performance, for especially true small-scale application, this just makes server resource not to be fully utilized.And use Intel Virtualization Technology to address this problem well.
Intel Virtualization Technology refers to: utilize software and hardware to combine, and physical server is divided into the virtual machine of several isolation, can working procedure and being independent of each other independently on each virtual machine.Intel Virtualization Technology physical resource is accomplished more fine-grained division, thus server resource is more fully utilized, and provides cost savings; Become software operation by the operation of physical hardware, make to dispose, that change, calamity are standby etc. is convenient; Compared to the multiple application program of unit operation, use virtual machine, the environment of application program is consistent with in physical machine, and O&M is simpler.
For cloud computing technology popular at present, Intel Virtualization Technology is exactly one of its core technology." namely infrastructure serve " (Infrastructure as a Service of cloud computing, IAAS) virtual platform is provided, utilize the feature that virtual deployment is succinct fast, user can according to the loading condition of application actual demand, and on platform, application or release virtual machine dynamically increase or reduce computing power easily.
When user is from the environmental transport and transfer of oneself to virtual platform, most hope can be moved smoothly, namely ensure that system is consistent with original with software environment, so just need P2V(Physical toVirtual, physical machine is to virtual machine) and V2V(Virtual to Virtual, virtual machine is to virtual machine) technology.P2V to refer to system from physical machine context conversion to virtual machine environment, makes virtual machine environment consistent with original physical machine environment; V2V refers to virtual machine environment system being transformed into another platform from the virtual machine environment of a platform, makes source and destination virtual machine environment consistent.
For P2V, a kind of typical way makes Ghost mirror image.Ghost is a backup software of Symantec company, supports system partitioning be made into an image file and return to system partitioning from image file.The step that use Ghost software carries out P2V is as follows:
1. the physical machine shutdown carrying out P2V will be needed;
2. prepare one with Ghost software can boot disk, from this disk startup system;
3. enter Ghost software interface, the Ghost mirror image of manufacturing system;
4. certain that the Ghost image copying made can be identified to virtual machine is independently on Physical Extents;
5. select suitable disk size to create virtual machine, the subregion preserving Ghost mirror image is set to an additional disk of virtual machine;
6. from the dish of Ghost software or .iso file start virtual machine;
7., in the Ghost environment in virtual machine, reduce from mirror image;
8. close virtual machine, the subregion coiling and preserve Ghost mirror image is removed from virtual machine; And
9. start virtual machine.
As can be seen here, it is very loaded down with trivial details for using Ghost software to perform P2V, and this is mainly reflected in following several aspect:
1. due to the operation characteristic of Ghost software, the machinery requirement carrying out P2V first shuts down, and starts from the dish with Ghost software;
The final object of 2.P2V is will by system from physical machine environmental transport and transfer to virtual machine environment, Ghost software reaches this purpose by the step of physical machine-> mirror image-> virtual machine, the middle mirror image produced just has not needed after generation virtual machine, but this process adds the time needed for P2V; And
3. image file needs extra storage space to preserve, when the system content that stores in physical machine itself is many, to the storage of image file with copy and waste storage space and IO interface resource.
For V2V, the mode identical with P2V can be adopted, namely also use Ghost software to be moved by the step of virtual machine 1-> mirror image-> virtual machine 2.
Because the disk great majority of virtual machine store with file mode, directly can pass through switching software, a kind of magnetic disk of virtual machine file of platform is directly transformed into the form that another platform can identify.Such as, can by the software virtual machine of VMware(VMware company by qemu-img instrument) the file transform of .vmdk form be the software virtual machine of Xen(Cambridge University exploitation) file of the .raw form that can identify or .qcow2 form.The step that above-mentioned use crossover tool carries out changing is as follows:
1. from the physical machine of source by magnetic disk of virtual machine file copy to object physical machine;
2. the form using disk crossover tool magnetic disk of virtual machine to be converted to object virtual machine platform in object physical machine can to identify;
3. create virtual machine, the disk file obtained after disk being set to format conversion; And
4. start virtual machine.
Use the mode of above-mentioned direct entiredisk form to compared with the mode performing V2V and use Ghost software, simplify a lot.But on the one hand, this mode is not general, that is, suitable conversion software can not be ensured to carry out the conversion of disc format; On the other hand, some magnetic disk of virtual machine is not self-propagation form, for the magnetic disk of virtual machine of this form, the size of data of disk size and storage is irrelevant, if only deposited little data in the disk that capacity is very large, need the magnetic disk of virtual machine of conversion also to remain very large, this brings a large amount of useless IO interface resource consumptions just to conversion and reproduction process.
Summary of the invention
In order at least solve the problems of the technologies described above, the invention provides a kind of method and apparatus for conversion operations system running environment, wherein by operating system from source physical machine environment or source virtual machine context conversion to object virtual machine environment.
According to a first aspect of the present invention, provide a kind of method for conversion operations system running environment, wherein by operating system from source physical machine environment or source virtual machine context conversion to object virtual machine environment, the method comprises:
According to the type of described operating system and described object virtual machine environment, the magnetic disk of virtual machine for described object virtual machine environment rebuilds the essential information of described operating system;
In described source physical machine environment or described source virtual machine environment, the file in described operating system is packed, and be written in described source physical machine environment or the transmission tunnel between described source virtual machine environment and described object virtual machine environment; And
By described transmission tunnel by the file transfer through packing to the destination locations in the magnetic disk of virtual machine of described object virtual machine environment, and to unpack.
Preferably, described method also comprises: before the magnetic disk of virtual machine being described object virtual machine environment according to the type of described operating system and described object virtual machine environment rebuilds the step of the essential information of described operating system, according to the size of the file in described operating system, create described magnetic disk of virtual machine.
Preferably, described method also comprises: by described transmission tunnel by through packing file transfer to the destination locations in the magnetic disk of virtual machine of described object virtual machine environment, and after carrying out the step unpacked, create configuration file and start described object virtual machine environment.
Preferably, when described object virtual machine environment is fully virtualized environment, the essential information of described operating system comprises guidance information, partition information and filesystem information.
Preferably, when described object virtual machine environment is half virtualized environment, the essential information of described operating system comprises filesystem information.
Preferably, described operating system is BSD operating system, and described method also comprises:
After the step creating described magnetic disk of virtual machine, before the magnetic disk of virtual machine being described object virtual machine environment according to the type of described operating system and described object virtual machine environment rebuilds the step of the essential information of described operating system, start BSD and virtual machine is installed, and described magnetic disk of virtual machine is tied on described BSD installation virtual machine; And
In described source physical machine environment or described source virtual machine environment, the file in described operating system is packed and after being written to the step in described source physical machine environment or the transmission tunnel between described source virtual machine environment and described object virtual machine environment, by described transmission tunnel by the file transfer through packing to the destination locations in described object virtual machine environment and before the step unpacked, at described BSD, magnetic disk of virtual machine described in carry on virtual machine is installed
Wherein, the described type according to described operating system and described object virtual machine environment is that step that the magnetic disk of virtual machine of described object virtual machine environment rebuilds the essential information of described operating system is installed on virtual machine at described BSD and performed.
Preferably, described operating system is (SuSE) Linux OS, and described method also comprises:
In described source physical machine environment or described source virtual machine environment, the file in described operating system is packed and after being written to the step in described source physical machine environment or the transmission tunnel between described source virtual machine environment and described object virtual machine environment, by described transmission tunnel by the file transfer through packing to the destination locations in described object virtual machine environment and before the step unpacked, magnetic disk of virtual machine described in carry on the physical host at described object virtual machine environment place
Wherein, the described type according to described operating system and described object virtual machine environment is that the step that the magnetic disk of virtual machine of described object virtual machine environment rebuilds the essential information of described operating system performs on described physical host.
Preferably, when packing to the file in described operating system, Virtual File System file and transmission tunnel file are not packed.
Preferably, described object virtual machine environment is Xen environment or KVM environment.
According to a second aspect of the present invention, provide a kind of device for conversion operations system running environment, wherein by operating system from source physical machine environment or source virtual machine context conversion to object virtual machine environment, this device comprises:
Rebuild module, for the type according to described operating system and described object virtual machine environment, the magnetic disk of virtual machine for described object virtual machine environment rebuilds the essential information of described operating system;
Packing and writing module, for in described source physical machine environment or described source virtual machine environment, file in described operating system is packed, and is written in described source physical machine environment or the transmission tunnel between described source virtual machine environment and described object virtual machine environment; And
Transmission and parse module, for by described transmission tunnel by the file transfer through packing to the destination locations in the magnetic disk of virtual machine of described object virtual machine environment, and to unpack.
Preferably, described device also comprises: creation module, for before the essential information of operating system described in described reconstruction module reconstructs, according to the size of the file in described operating system, creates described magnetic disk of virtual machine.
Preferably, described device also comprises: create and start module, for by described transmission tunnel at described transmission and parse module the file transfer through packing after unpacking to the destination locations in the magnetic disk of virtual machine of described object virtual machine environment, being created configuration file and starts described object virtual machine environment.
Preferably, when described object virtual machine environment is fully virtualized environment, the essential information of described operating system comprises guidance information, partition information and filesystem information.
Preferably, when described object virtual machine environment is half virtualized environment, the essential information of described operating system comprises filesystem information.
Preferably, described operating system is BSD operating system, and described device also comprises:
For after creating described magnetic disk of virtual machine in described creation module, before the essential information of operating system described in described reconstruction module reconstructs, start BSD and the startup module of virtual machine is installed and described magnetic disk of virtual machine is tied to described BSD binding module on virtual machine is installed; And
First carry module, for to pack to the file in described operating system at described packing and writing module and by the file transfer through packing to the destination locations in described object virtual machine environment and before unpacking after being written in described transmission tunnel, at described transmission and parse module, at described BSD, magnetic disk of virtual machine described in carry on virtual machine is installed
Wherein, described reconstruction module is installed on virtual machine at described BSD and is rebuild the essential information of described operating system.
Preferably, described operating system is (SuSE) Linux OS, and described device also comprises:
Second carry module, for to pack to the file in described operating system at described packing and writing module and by the file transfer through packing to the destination locations in described object virtual machine environment and before unpacking after being written in described transmission tunnel, at described transmission and parse module, magnetic disk of virtual machine described in carry on the physical host at described object virtual machine environment place
Wherein, described reconstruction module rebuilds the essential information of described operating system on described physical host.
Preferably, described packing and writing module, when packing to the file in described operating system, are not packed to Virtual File System file and transmission tunnel file.
Preferably, described object virtual machine environment is Xen environment or KVM environment.
The invention provides a kind of method and apparatus for conversion operations system running environment, wherein by operating system from source physical machine environment or source virtual machine context conversion to object virtual machine environment (that is, P2V or V2V).According to an embodiment of the invention for the method and apparatus of P2V and V2V, for P2V, extra storage space is not needed to preserve mirror image; For V2V, do not need additional space to preserve or former format disc, the size of data copied is exactly the size of actual storage data, therefore all very little for P2V and V2V expense in storage space; And support online P2V and V2V; namely P2V or V2V can be performed under source physical machine or the non-stop-machine situation of virtual machine; and owing to not needing the physical operations for shutting down such as power-off restarting; whole P2V or V2V process is convenient to robotization and batch operation, drastically increases the efficiency of P2V or V2V operation.
Accompanying drawing explanation
According to the detailed description below in conjunction with accompanying drawing, above and other object of the present invention and feature will become clearly, wherein:
Fig. 1 is according to an embodiment of the invention for the process flow diagram of the method for conversion operations system running environment;
Fig. 2 is according to an embodiment of the invention for the schematic diagram of the step S120 in the method for conversion operations system running environment and S130; And
Fig. 3 is according to an embodiment of the invention for the block diagram of the device of conversion operations system running environment.
Embodiment
In the following detailed description, in order to the object with example is described, several details are described, to provide the complete understanding for each embodiment.But, for those of ordinary skills, these embodiments can be realized when there is no these details.The component names used in the following description is only used to easy explanation, instead of in order to carry out any restriction.
Fig. 1 is according to an embodiment of the invention for the process flow diagram of the method for conversion operations system running environment.
According to embodiments of the invention, described operating system includes but not limited to the desktop level operating systems such as (SuSE) Linux OS, BSD operating system, Unix operating system, Windows operating system, Mac OS operating system, Chrome OS operating system, and the mobile platform operating system such as Android operation system, iOS operating system; Described physical machine environment comprises the various electronic equipments that can run aforesaid operations system, includes but not limited to: desk-top computer, notebook, Tablet PC, mainframe computer, mobile phone, panel computer, navigating instrument, audio frequency and/or video player, radio, mobile TV, Set Top Box etc.; Source virtual machine environment and object virtual machine environment include but not limited to Xen virtual machine environment, KVM virtual machine environment, VMware virtual machine environment, VirtualBox virtual machine environment, Virtual PC virtual machine environment etc.
Hereinafter, for (SuSE) Linux OS and BSD operating system, Xen virtual machine environment and KVM virtual machine environment, exemplary description is carried out to principle of the present invention, but this description is only exemplary, scope of the present invention is not limited to this, principle of the present invention also go for above-mentioned other operating system and virtual machine environment.
See Fig. 1, according to an embodiment of the invention in the method 100 of conversion operations system running environment, by operating system from source physical machine environment or source virtual machine context conversion to object virtual machine environment (that is, P2V or V2V).At the beginning, in step s 110, according to the type of described operating system and described object virtual machine environment, the magnetic disk of virtual machine for described object virtual machine environment rebuilds the essential information of described operating system.Before step S 110, also to perform step S 101: according to the size of the file in described operating system, create described magnetic disk of virtual machine.Step S101 such as can be realized by establishment file or block device.For Xen virtual machine environment and KVM virtual machine environment, lvcreate order can be used to create block device, or use dd or qemu-img order to create file.
In addition, for BSD operating system, after step slol, before step S110, also following steps will be performed: start BSD and virtual machine (step S102) is installed, and described magnetic disk of virtual machine binding (attach) is installed on virtual machine (step S 103) to described BSD, this is because for BSD operating system, to install on virtual machine at this BSD and perform above-mentioned steps S110.And for (SuSE) Linux OS, can at the physical host (that is, object physical host) at described object virtual machine environment place upper execution above-mentioned steps S110.
According to embodiments of the invention, when described object virtual machine environment is fully virtualized environment, the essential information of described operating system comprises guidance information, partition information and filesystem information.
When KVM virtual machine environment or Xen virtual machine environment run (SuSE) Linux OS as the fully virtualized environment of object, according to the characteristic of (SuSE) Linux OS, for the purpose of on object physical host, the magnetic disk of virtual machine of virtual machine environment (KVM or Xen) is rebuild the step that (SuSE) Linux OS runs essential information and can be comprised: (1) rebuilds partition information, such as, rebuild the partition table by fdisk or parted order; (2) reset file system information, such as, by mkfs order reset file system on the subregion rebuild; And (3) rebuild guidance information, such as, by grub Installing of Command bootloader(boot loader) perform.
When KVM virtual machine environment or Xen virtual machine environment run BSD operating system as the fully virtualized environment of object, according to the characteristic of BSD operating system, the step of installing the essential information of magnetic disk of virtual machine reconstruction BSD operating system of virtual machine environment (KVM or Xen) for the purpose of on virtual machine at BSD can comprise:
(1) guidance information is rebuild
Due in BSD system by mbr(master boot record, Main Boot Record) under information is kept at local/boot/mbr file, therefore such as can by rebuilding guidance information (mbr) as issued orders in this locality:
fdisk-aBI-b/boot/mbr$DISK。
(2) partition information is rebuild
Disklabel order such as can be used to rebuild partition information.First what a partition table configuration file is prepared, such as
c:*0unused 0 0 0
a:*04.2BSD000
Then partition information is rebuild by disklabel-w, disklabel-B, disklabel – R order by partition table configuration file.
(3) reset file system information
Such as can create virtual machine file system by newfs order.
According to embodiments of the invention, when described object virtual machine environment is half virtualized environment, the essential information of described operating system comprises filesystem information.
Xen virtual machine environment can run (SuSE) Linux OS as object half virtualized environment.Due to half virtualized characteristic, when system starts without the need to reading guidance information, but by the kernel that configures in configuration file or pygrub(boot loader) load kernel(system kernel), therefore when half is virtual guidance information without the need to rebuilding.In addition, due to half virtualized characteristic, partition information can directly be specified in configuration file, therefore when half is virtual guidance information also without the need to rebuild.Like this, only need reset file system information, this such as can be realized magnetic disk of virtual machine file reconstruction file system by mkfs order on object physical host.
According to embodiments of the invention, and see Fig. 1, after step silo, perform step S120 and step S130: in described source physical machine environment or described source virtual machine environment, file in described operating system is packed, and be written in described source physical machine environment or the transmission tunnel between described source virtual machine environment and described object virtual machine environment (step S120), and by described transmission tunnel by the file transfer through packing to the destination locations in the magnetic disk of virtual machine of described object virtual machine environment, and carry out unpacking (step S130).In addition, after above-mentioned steps S120, before step S130, for BSD operating system, perform step S121: at BSD, carry (mount) described magnetic disk of virtual machine on virtual machine is installed; And for (SuSE) Linux OS, perform step S121 ': magnetic disk of virtual machine described in carry on the physical host at described object virtual machine environment place.
Be described step S 120 and step 130 referring to Fig. 2, Fig. 2 is the schematic diagram of step S120 according to an embodiment of the invention in method 100 and S130.See Fig. 2, in the source physical machine environment or source virtual machine environment in left side, file in operating system is packed, described file comprises file and the user file of operating system self, but does not pack to the Virtual File System files such as such as/cgroup ,/proc ,/sys and transmission tunnel file.Afterwards, the file through packing is written in transmission tunnel (such as ssh tunnel).Then, by transmitting tunnel by the file transfer through packing to the destination locations in the magnetic disk of virtual machine of the object virtual machine environment on right side, and at this destination locations, file is unpacked.In above process, file is directly write in transmission tunnel while packing, then by transmission tunnel, file transfer is unpacked file at this destination locations to the destination locations in the magnetic disk of virtual machine of object virtual machine environment, only have Internet Transmission to operate in whole process, and there is not extra intermediate file storage.
According to embodiments of the invention, after step s 130, step S131 is performed: create configuration file and start described object virtual machine environment.Described configuration file can be used for configuring the hardware devices such as CPU (central processing unit) (CPU), internal memory.
The invention provides a kind of method for conversion operations system running environment, wherein by operating system from source physical machine environment or source virtual machine context conversion to object virtual machine environment.According to an embodiment of the invention for the method for P2V and V2V, for P2V, extra storage space is not needed to preserve mirror image; For V2V, do not need additional space to preserve or former format disc, the size of data copied is exactly the size of actual storage data, therefore all very little for P2V and V2V expense in storage space; Support online P2V and V2V; namely P2V or V2V can be performed under source physical machine or the non-stop-machine situation of virtual machine; and owing to not needing the physical operations for shutting down such as power-off restarting, whole P2V or V2V process is convenient to robotization and batch operation, drastically increase the efficiency of P2V or V2V operation.
Corresponding with above-mentioned method 100, present invention also offers a kind of device 200 for conversion operations system running environment, wherein by operating system from source physical machine environment or source virtual machine context conversion to object virtual machine environment, see Fig. 3, this device 200 comprises:
Rebuild module 210, for the type according to described operating system and described object virtual machine environment, magnetic disk of virtual machine for described object virtual machine environment rebuilds the essential information of described operating system, and this reconstruction module 210 may be used for performing the step S110 in said method 100;
Packing and writing module 220, for in described source physical machine environment or described source virtual machine environment, file in described operating system is packed, and be written in described source physical machine environment or the transmission tunnel between described source virtual machine environment and described object virtual machine environment, this packing and writing module 220 may be used for performing the step S120 in said method 100; And
Transmission and parse module 230, for by described transmission tunnel by through packing file transfer to the destination locations in the magnetic disk of virtual machine of described object virtual machine environment, and unpack, this transmission and parse module 230 may be used for performing the step S130 in said method 100.
In a preferred embodiment of the invention, described device also comprises: creation module 201, before rebuilding the essential information of described operating system in described reconstruction module 210, according to the size of the file in described operating system, create described magnetic disk of virtual machine, described creation module 201 may be used for performing the step S101 in said method 100.
In a preferred embodiment of the invention, described device also comprises: create and start module 231, for at described transmission and parse module 230 by described transmission tunnel by the file transfer through packing to the destination locations in the magnetic disk of virtual machine of described object virtual machine environment and after unpacking, create configuration file and start described object virtual machine environment, described establishment and startup module 231 may be used for performing the step S131 in said method 100.
In a preferred embodiment of the invention, when described object virtual machine environment is fully virtualized environment, the essential information of described operating system comprises guidance information, partition information and filesystem information.
In a preferred embodiment of the invention, when described object virtual machine environment is half virtualized environment, the essential information of described operating system comprises filesystem information.
In a preferred embodiment of the invention, described operating system is BSD operating system, and described device also comprises:
For after creating described magnetic disk of virtual machine in described creation module 201, before described reconstruction module 210 rebuilds the essential information of described operating system, start the startup module 202 that BSD installs virtual machine and the binding module 203 described magnetic disk of virtual machine be tied on described BSD installation virtual machine, described startup module 202 and binding module 203 can be respectively used to perform the step S102 in said method 100 and step S103; And
First carry module 221, for to pack to the file in described operating system at described packing and writing module 220 and by the file transfer through packing to the destination locations in described object virtual machine environment and before unpacking after being written in described transmission tunnel, at described transmission and parse module 230, magnetic disk of virtual machine described in carry on described installation virtual machine, described first carry module 221 may be used for performing the step S121 in said method 100
Wherein, described reconstruction module 210 rebuilds the essential information of described operating system on described installation virtual machine.
In a preferred embodiment of the invention, described operating system is (SuSE) Linux OS, and described device also comprises:
Second carry module 221', for to pack to the file in described operating system at described packing and writing module 220 and by the file transfer through packing to the destination locations in described object virtual machine environment and before unpacking after being written in described transmission tunnel, at described transmission and parse module 230, magnetic disk of virtual machine described in carry on the physical host at described object virtual machine environment place, described second carry module 221 ' may be used for performing the step S121 ' in said method 100
Wherein, described reconstruction module 210 rebuilds the essential information of described operating system on described physical host.
In a preferred embodiment of the invention, described packing and writing module 220, when packing to the file in described operating system, are not packed to Virtual File System file and transmission tunnel file.
In a preferred embodiment of the invention, described object virtual machine environment is Xen environment or KVM environment.
Because above-mentioned each device embodiment is corresponding with aforementioned approaches method embodiment, therefore no longer each device embodiment is described in detail.
The present invention can realize in any suitable form, comprises hardware, software, firmware or their combination in any.Alternatively, the present invention can be embodied as the computer software operated on one or more processor and/or digital signal processor at least in part.The device of embodiments of the invention and module can realize physically, functionally and in logic in any suitable manner.Can the part in individual unit, in multiple unit or as other functional units realize according to each function of the present invention.Similarly, the present invention can realize in individual unit, or can be distributed between different units and processor physically and functionally.
Although describe the present invention in conjunction with some embodiments, the present invention is not intended to be limited to the particular form set forth herein.On the contrary, scope of the present invention is only defined by the appended claims.In addition, be described in conjunction with specific embodiment although feature may look like, those of ordinary skill in the art will be appreciated that, can combine the various features of described embodiment according to the present invention.In detail in the claims, word " comprises " existence not getting rid of other modules or step.
In addition, although be listed separately, multiple module or method step can be realized by such as individual unit or processor.In addition, although independent feature may comprise in different claims, these features can advantageously be combined possibly, and comprise in different claims and do not mean that the combination of feature is infeasible.In addition, feature to be contained in a kind of claim categories (such as claim to a method) and not to mean that and is limited to this classification, but represents that this feature suitably can be applied to other claim categories (such as device claim) equally.In addition, in claim feature order and do not mean that necessary any particular order.Further, in claim to a method each step order and do not mean that these steps must perform according to this order.On the contrary, these steps can perform with any order suitably.In addition, the statement of singulative does not get rid of plural number.Therefore, plural number is not got rid of for quoting of " ", " ", " first ", " second " etc.Reference numeral in claim is only label, and should not be regarded as the restriction of the scope to claim.