@@ -287,6 +287,11 @@ private static boolean isAlienVm(final VM vm, final Connection conn) throws XenA
287287
288288 protected StorageSubsystemCommandHandler storageHandler ;
289289
290+ private static final String XENSTORE_DATA_IP = "vm-data/ip" ;
291+ private static final String XENSTORE_DATA_GATEWAY = "vm-data/gateway" ;
292+ private static final String XENSTORE_DATA_NETMASK = "vm-data/netmask" ;
293+ private static final String XENSTORE_DATA_CS_INIT = "vm-data/cloudstack/init" ;
294+
290295 public CitrixResourceBase () {
291296 }
292297
@@ -1285,7 +1290,6 @@ public VM createVmFromTemplate(final Connection conn, final VirtualMachineTO vmS
12851290 if (guestOsDetails .containsKey ("xenserver.dynamicMax" )) {
12861291 recommendedMemoryMax = Long .valueOf (guestOsDetails .get ("xenserver.dynamicMax" )).longValue ();
12871292 }
1288-
12891293 }
12901294
12911295 if (isDmcEnabled (conn , host ) && vmSpec .isEnableDynamicallyScaleVm ()) {
@@ -1309,7 +1313,6 @@ public VM createVmFromTemplate(final Connection conn, final VirtualMachineTO vmS
13091313 vmr .memoryStaticMin = vmSpec .getMinRam ();
13101314 vmr .memoryStaticMax = vmSpec .getMaxRam ();
13111315 vmr .memoryDynamicMin = vmSpec .getMinRam ();
1312- ;
13131316 vmr .memoryDynamicMax = vmSpec .getMaxRam ();
13141317
13151318 vmr .VCPUsMax = (long )vmSpec .getCpus ();
@@ -1323,17 +1326,15 @@ public VM createVmFromTemplate(final Connection conn, final VirtualMachineTO vmS
13231326 NicTO mgmtNic = vmSpec .getNics ()[0 ];
13241327 if (mgmtNic != null ) {
13251328 Map <String , String > xenstoreData = new HashMap <String , String >(3 );
1326- xenstoreData .put ("vm-data/ip" , mgmtNic .getIp ().toString ().trim ());
1327- xenstoreData .put ("vm-data/gateway" , mgmtNic .getGateway ().toString ().trim ());
1328- xenstoreData .put ("vm-data/netmask" , mgmtNic .getNetmask ().toString ().trim ());
1329+ xenstoreData .put (XENSTORE_DATA_IP , mgmtNic .getIp ().toString ().trim ());
1330+ xenstoreData .put (XENSTORE_DATA_GATEWAY , mgmtNic .getGateway ().toString ().trim ());
1331+ xenstoreData .put (XENSTORE_DATA_NETMASK , mgmtNic .getNetmask ().toString ().trim ());
13291332 vmr .xenstoreData = xenstoreData ;
13301333 }
13311334 }
13321335
13331336 final VM vm = VM .create (conn , vmr );
1334- if (s_logger .isDebugEnabled ()) {
1335- s_logger .debug ("Created VM " + vm .getUuid (conn ) + " for " + vmSpec .getName ());
1336- }
1337+ s_logger .debug ("Created VM " + vm .getUuid (conn ) + " for " + vmSpec .getName ());
13371338
13381339 final Map <String , String > vcpuParams = new HashMap <String , String >();
13391340
@@ -1365,12 +1366,18 @@ public VM createVmFromTemplate(final Connection conn, final VirtualMachineTO vmS
13651366
13661367 final String bootArgs = vmSpec .getBootArgs ();
13671368 if (bootArgs != null && bootArgs .length () > 0 ) {
1369+ // send boot args for PV instances
13681370 String pvargs = vm .getPVArgs (conn );
13691371 pvargs = pvargs + vmSpec .getBootArgs ().replaceAll (" " , "%" );
1370- if (s_logger .isDebugEnabled ()) {
1371- s_logger .debug ("PV args are " + pvargs );
1372- }
13731372 vm .setPVArgs (conn , pvargs );
1373+ s_logger .debug ("PV args are " + pvargs );
1374+
1375+ // send boot args into xenstore-data for HVM instances
1376+ Map <String , String > xenstoreData = new HashMap <>();
1377+
1378+ xenstoreData .put (XENSTORE_DATA_CS_INIT , bootArgs );
1379+ vm .setXenstoreData (conn , xenstoreData );
1380+ s_logger .debug ("HVM args are " + bootArgs );
13741381 }
13751382
13761383 if (!(guestOsTypeName .startsWith ("Windows" ) || guestOsTypeName .startsWith ("Citrix" ) || guestOsTypeName .startsWith ("Other" ))) {
0 commit comments