1616// under the License.
1717package com .cloud .hypervisor .kvm .resource ;
1818
19+ import java .io .BufferedOutputStream ;
20+ import java .io .BufferedReader ;
21+ import java .io .File ;
22+ import java .io .FileNotFoundException ;
23+ import java .io .FileOutputStream ;
24+ import java .io .FileReader ;
25+ import java .io .IOException ;
26+ import java .io .InputStream ;
27+ import java .io .InputStreamReader ;
28+ import java .io .Reader ;
29+ import java .net .InetAddress ;
30+ import java .net .URI ;
31+ import java .net .URISyntaxException ;
32+ import java .net .URL ;
33+ import java .net .URLConnection ;
34+ import java .text .DateFormat ;
35+ import java .text .MessageFormat ;
36+ import java .text .SimpleDateFormat ;
37+ import java .util .ArrayList ;
38+ import java .util .Arrays ;
39+ import java .util .Calendar ;
40+ import java .util .Collections ;
41+ import java .util .Comparator ;
42+ import java .util .Date ;
43+ import java .util .HashMap ;
44+ import java .util .HashSet ;
45+ import java .util .List ;
46+ import java .util .Map ;
47+ import java .util .Properties ;
48+ import java .util .Set ;
49+ import java .util .UUID ;
50+ import java .util .concurrent .Callable ;
51+ import java .util .concurrent .ConcurrentHashMap ;
52+ import java .util .concurrent .ExecutionException ;
53+ import java .util .concurrent .ExecutorService ;
54+ import java .util .concurrent .Executors ;
55+ import java .util .concurrent .Future ;
56+ import java .util .concurrent .TimeUnit ;
57+ import java .util .concurrent .TimeoutException ;
58+ import java .util .regex .Matcher ;
59+ import java .util .regex .Pattern ;
60+
61+ import javax .ejb .Local ;
62+ import javax .naming .ConfigurationException ;
63+
64+ import org .apache .commons .io .FileUtils ;
65+ import org .apache .commons .io .IOUtils ;
66+ import org .apache .log4j .Logger ;
67+ import org .libvirt .Connect ;
68+ import org .libvirt .Domain ;
69+ import org .libvirt .DomainBlockStats ;
70+ import org .libvirt .DomainInfo ;
71+ import org .libvirt .DomainInterfaceStats ;
72+ import org .libvirt .DomainSnapshot ;
73+ import org .libvirt .LibvirtException ;
74+ import org .libvirt .NodeInfo ;
75+ import org .libvirt .StorageVol ;
76+
1977import com .ceph .rados .IoCTX ;
2078import com .ceph .rados .Rados ;
2179import com .ceph .rados .RadosException ;
2280import com .ceph .rbd .Rbd ;
2381import com .ceph .rbd .RbdException ;
2482import com .ceph .rbd .RbdImage ;
83+
84+ import org .apache .cloudstack .storage .command .StorageSubSystemCommand ;
85+ import org .apache .cloudstack .storage .to .PrimaryDataStoreTO ;
86+ import org .apache .cloudstack .storage .to .VolumeObjectTO ;
87+ import org .apache .cloudstack .utils .qemu .QemuImg ;
88+ import org .apache .cloudstack .utils .qemu .QemuImg .PhysicalDiskFormat ;
89+ import org .apache .cloudstack .utils .qemu .QemuImgException ;
90+ import org .apache .cloudstack .utils .qemu .QemuImgFile ;
91+
2592import com .cloud .agent .api .Answer ;
2693import com .cloud .agent .api .AttachIsoCommand ;
2794import com .cloud .agent .api .AttachVolumeAnswer ;
202269import com .cloud .vm .VirtualMachine .PowerState ;
203270import com .cloud .vm .VirtualMachine .State ;
204271
205- import org .apache .cloudstack .storage .command .StorageSubSystemCommand ;
206- import org .apache .cloudstack .storage .to .PrimaryDataStoreTO ;
207- import org .apache .cloudstack .storage .to .VolumeObjectTO ;
208- import org .apache .cloudstack .utils .qemu .QemuImg ;
209- import org .apache .cloudstack .utils .qemu .QemuImg .PhysicalDiskFormat ;
210- import org .apache .cloudstack .utils .qemu .QemuImgException ;
211- import org .apache .cloudstack .utils .qemu .QemuImgFile ;
212- import org .apache .commons .io .FileUtils ;
213- import org .apache .commons .io .IOUtils ;
214- import org .apache .log4j .Logger ;
215- import org .libvirt .Connect ;
216- import org .libvirt .Domain ;
217- import org .libvirt .DomainBlockStats ;
218- import org .libvirt .DomainInfo ;
219- import org .libvirt .DomainInterfaceStats ;
220- import org .libvirt .DomainSnapshot ;
221- import org .libvirt .LibvirtException ;
222- import org .libvirt .NodeInfo ;
223- import org .libvirt .StorageVol ;
224-
225- import javax .ejb .Local ;
226- import javax .naming .ConfigurationException ;
227-
228- import java .io .BufferedOutputStream ;
229- import java .io .BufferedReader ;
230- import java .io .File ;
231- import java .io .FileNotFoundException ;
232- import java .io .FileOutputStream ;
233- import java .io .FileReader ;
234- import java .io .IOException ;
235- import java .io .InputStream ;
236- import java .io .InputStreamReader ;
237- import java .io .Reader ;
238- import java .net .InetAddress ;
239- import java .net .URI ;
240- import java .net .URISyntaxException ;
241- import java .net .URL ;
242- import java .net .URLConnection ;
243- import java .text .DateFormat ;
244- import java .text .MessageFormat ;
245- import java .text .SimpleDateFormat ;
246- import java .util .ArrayList ;
247- import java .util .Arrays ;
248- import java .util .Calendar ;
249- import java .util .Collections ;
250- import java .util .Comparator ;
251- import java .util .Date ;
252- import java .util .HashMap ;
253- import java .util .HashSet ;
254- import java .util .List ;
255- import java .util .Map ;
256- import java .util .Properties ;
257- import java .util .Set ;
258- import java .util .UUID ;
259- import java .util .concurrent .Callable ;
260- import java .util .concurrent .ConcurrentHashMap ;
261- import java .util .concurrent .ExecutionException ;
262- import java .util .concurrent .ExecutorService ;
263- import java .util .concurrent .Executors ;
264- import java .util .concurrent .Future ;
265- import java .util .concurrent .TimeoutException ;
266- import java .util .concurrent .TimeUnit ;
267- import java .util .regex .Matcher ;
268- import java .util .regex .Pattern ;
269-
270272/**
271273 * LibvirtComputingResource execute requests on the computing/routing host using
272274 * the libvirt API
@@ -2013,7 +2015,7 @@ private void VifHotPlug(Connect conn, String vmName, String broadcastUri, String
20132015 }
20142016
20152017 Domain vm = getDomain (conn , vmName );
2016- vm .attachDevice (getVifDriver (nicTO .getType ()).plug (nicTO , "Other PV (32-bit) " , "" ).toString ());
2018+ vm .attachDevice (getVifDriver (nicTO .getType ()).plug (nicTO , "Other PV" , "" ).toString ());
20172019 }
20182020
20192021
@@ -2050,7 +2052,7 @@ private PlugNicAnswer execute(PlugNicCommand cmd) {
20502052 }
20512053 nicnum ++;
20522054 }
2053- vm .attachDevice (getVifDriver (nic .getType ()).plug (nic , "Other PV (32-bit) " , "" ).toString ());
2055+ vm .attachDevice (getVifDriver (nic .getType ()).plug (nic , "Other PV" , "" ).toString ());
20542056 return new PlugNicAnswer (cmd , true , "success" );
20552057 } catch (LibvirtException e ) {
20562058 String msg = " Plug Nic failed due to " + e .toString ();
@@ -3648,6 +3650,7 @@ protected LibvirtVMDef createVMFromSpec(VirtualMachineTO vmTO) {
36483650 uuid = getUuid (uuid );
36493651 vm .setDomUUID (uuid );
36503652 vm .setDomDescription (vmTO .getOs ());
3653+ vm .setPlatformEmulator (vmTO .getPlatformEmulator ());
36513654
36523655 GuestDef guest = new GuestDef ();
36533656
@@ -3961,9 +3964,8 @@ public int compare(DiskTO arg0, DiskTO arg1) {
39613964 }
39623965
39633966 if (diskBusType == null ) {
3964- diskBusType = getGuestDiskModel (vmSpec .getOs ());
3967+ diskBusType = getGuestDiskModel (vmSpec .getPlatformEmulator ());
39653968 }
3966-
39673969 DiskDef disk = new DiskDef ();
39683970 if (volume .getType () == Volume .Type .ISO ) {
39693971 if (volPath == null ) {
@@ -4043,7 +4045,7 @@ public int compare(DiskTO arg0, DiskTO arg1) {
40434045 }
40444046
40454047 private void createVif (LibvirtVMDef vm , NicTO nic , String nicAdapter ) throws InternalErrorException , LibvirtException {
4046- vm .getDevices ().addDevice (getVifDriver (nic .getType ()).plug (nic , vm .getGuestOSType (), nicAdapter ).toString ());
4048+ vm .getDevices ().addDevice (getVifDriver (nic .getType ()).plug (nic , vm .getPlatformEmulator (). toString (), nicAdapter ).toString ());
40474049 }
40484050
40494051 protected CheckSshAnswer execute (CheckSshCommand cmd ) {
@@ -4977,16 +4979,15 @@ private String getGuestType(Connect conn, String vmName) {
49774979 }
49784980 }
49794981
4980- boolean isGuestPVEnabled (String guestOS ) {
4981- if (guestOS == null ) {
4982+ boolean isGuestPVEnabled (String guestOSName ) {
4983+ if (guestOSName == null ) {
49824984 return false ;
49834985 }
4984- String guestOSName = KVMGuestOsMapper .getGuestOsName (guestOS );
4985- if (guestOS .startsWith ("Ubuntu" ) || guestOSName .startsWith ("Fedora 13" ) || guestOSName .startsWith ("Fedora 12" ) || guestOSName .startsWith ("Fedora 11" ) ||
4986+ if (guestOSName .startsWith ("Ubuntu" ) || guestOSName .startsWith ("Fedora 13" ) || guestOSName .startsWith ("Fedora 12" ) || guestOSName .startsWith ("Fedora 11" ) ||
49864987 guestOSName .startsWith ("Fedora 10" ) || guestOSName .startsWith ("Fedora 9" ) || guestOSName .startsWith ("CentOS 5.3" ) || guestOSName .startsWith ("CentOS 5.4" ) ||
4987- guestOSName .startsWith ("CentOS 5.5" ) || guestOS .startsWith ("CentOS" ) || guestOS .startsWith ("Fedora" ) ||
4988+ guestOSName .startsWith ("CentOS 5.5" ) || guestOSName .startsWith ("CentOS" ) || guestOSName .startsWith ("Fedora" ) ||
49884989 guestOSName .startsWith ("Red Hat Enterprise Linux 5.3" ) || guestOSName .startsWith ("Red Hat Enterprise Linux 5.4" ) ||
4989- guestOSName .startsWith ("Red Hat Enterprise Linux 5.5" ) || guestOSName .startsWith ("Red Hat Enterprise Linux 6" ) || guestOS .startsWith ("Debian GNU/Linux" ) ||
4990+ guestOSName .startsWith ("Red Hat Enterprise Linux 5.5" ) || guestOSName .startsWith ("Red Hat Enterprise Linux 6" ) || guestOSName .startsWith ("Debian GNU/Linux" ) ||
49904991 guestOSName .startsWith ("FreeBSD 10" ) || guestOSName .startsWith ("Other PV" )) {
49914992 return true ;
49924993 } else {
@@ -5002,8 +5003,8 @@ public boolean isCentosHost() {
50025003 }
50035004 }
50045005
5005- private DiskDef .diskBus getGuestDiskModel (String guestOSType ) {
5006- if (isGuestPVEnabled (guestOSType )) {
5006+ private DiskDef .diskBus getGuestDiskModel (String platformEmulator ) {
5007+ if (isGuestPVEnabled (platformEmulator )) {
50075008 return DiskDef .diskBus .VIRTIO ;
50085009 } else {
50095010 return DiskDef .diskBus .IDE ;
0 commit comments