OLD | NEW |
1 #!/usr/bin/python | 1 #!/usr/bin/python |
2 """ | 2 """ |
3 Utility classes and functions to handle Virtual Machine creation using qemu. | 3 Utility classes and functions to handle Virtual Machine creation using qemu. |
4 | 4 |
5 @copyright: 2008-2009 Red Hat Inc. | 5 @copyright: 2008-2009 Red Hat Inc. |
6 """ | 6 """ |
7 | 7 |
8 import time, socket, os, logging, fcntl, re, commands, glob | 8 import time, socket, os, logging, fcntl, re, commands, glob |
9 import kvm_utils, kvm_subprocess, kvm_monitor, rss_file_transfer | 9 import kvm_utils, kvm_subprocess, kvm_monitor, rss_file_transfer |
10 from autotest_lib.client.common_lib import error | 10 from autotest_lib.client.common_lib import error |
(...skipping 217 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
228 if index is not None: cmd += ",index=%s" % index | 228 if index is not None: cmd += ",index=%s" % index |
229 if format: cmd += ",if=%s" % format | 229 if format: cmd += ",if=%s" % format |
230 if cache: cmd += ",cache=%s" % cache | 230 if cache: cmd += ",cache=%s" % cache |
231 if werror: cmd += ",werror=%s" % werror | 231 if werror: cmd += ",werror=%s" % werror |
232 if serial: cmd += ",serial='%s'" % serial | 232 if serial: cmd += ",serial='%s'" % serial |
233 if snapshot: cmd += ",snapshot=on" | 233 if snapshot: cmd += ",snapshot=on" |
234 if boot: cmd += ",boot=on" | 234 if boot: cmd += ",boot=on" |
235 return cmd | 235 return cmd |
236 | 236 |
237 def add_nic(help, vlan, model=None, mac=None, netdev_id=None): | 237 def add_nic(help, vlan, model=None, mac=None, netdev_id=None): |
238 cmd = " -net nic,vlan=%d" % vlan | |
239 if has_option(help, "netdev"): | 238 if has_option(help, "netdev"): |
240 cmd +=",netdev=%s" % netdev_id | 239 cmd = " -net nic,netdev=%s" % netdev_id |
| 240 else: |
| 241 cmd = " -net nic,vlan=%d" % vlan |
241 if model: cmd += ",model=%s" % model | 242 if model: cmd += ",model=%s" % model |
242 if mac: cmd += ",macaddr='%s'" % mac | 243 if mac: cmd += ",macaddr='%s'" % mac |
243 return cmd | 244 return cmd |
244 | 245 |
245 def add_net(help, vlan, mode, ifname=None, script=None, | 246 def add_net(help, vlan, mode, ifname=None, script=None, |
246 downscript=None, tftp=None, bootfile=None, hostfwd=[], | 247 downscript=None, tftp=None, bootfile=None, hostfwd=[], |
247 netdev_id=None): | 248 netdev_id=None): |
248 if has_option(help, "netdev"): | 249 if has_option(help, "netdev"): |
249 cmd = " -netdev %s,id=%s" % (mode, netdev_id) | 250 cmd = " -netdev %s,id=%s" % (mode, netdev_id) |
250 else: | 251 else: |
(...skipping 935 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1186 finally: | 1187 finally: |
1187 session.close() | 1188 session.close() |
1188 | 1189 |
1189 | 1190 |
1190 def get_current_memory_size(self): | 1191 def get_current_memory_size(self): |
1191 """ | 1192 """ |
1192 Get current memory size of the VM, rather than bootup memory. | 1193 Get current memory size of the VM, rather than bootup memory. |
1193 """ | 1194 """ |
1194 cmd = self.params.get("mem_chk_cur_cmd") | 1195 cmd = self.params.get("mem_chk_cur_cmd") |
1195 return self.get_memory_size(cmd) | 1196 return self.get_memory_size(cmd) |
OLD | NEW |