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 |
238 if has_option(help, "netdev"): | 239 if has_option(help, "netdev"): |
239 cmd = " -net nic,netdev=%s" % netdev_id | 240 cmd +=",netdev=%s" % netdev_id |
240 else: | |
241 cmd = " -net nic,vlan=%d" % vlan | |
242 if model: cmd += ",model=%s" % model | 241 if model: cmd += ",model=%s" % model |
243 if mac: cmd += ",macaddr='%s'" % mac | 242 if mac: cmd += ",macaddr='%s'" % mac |
244 return cmd | 243 return cmd |
245 | 244 |
246 def add_net(help, vlan, mode, ifname=None, script=None, | 245 def add_net(help, vlan, mode, ifname=None, script=None, |
247 downscript=None, tftp=None, bootfile=None, hostfwd=[], | 246 downscript=None, tftp=None, bootfile=None, hostfwd=[], |
248 netdev_id=None): | 247 netdev_id=None): |
249 if has_option(help, "netdev"): | 248 if has_option(help, "netdev"): |
250 cmd = " -netdev %s,id=%s" % (mode, netdev_id) | 249 cmd = " -netdev %s,id=%s" % (mode, netdev_id) |
251 else: | 250 else: |
(...skipping 935 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1187 finally: | 1186 finally: |
1188 session.close() | 1187 session.close() |
1189 | 1188 |
1190 | 1189 |
1191 def get_current_memory_size(self): | 1190 def get_current_memory_size(self): |
1192 """ | 1191 """ |
1193 Get current memory size of the VM, rather than bootup memory. | 1192 Get current memory size of the VM, rather than bootup memory. |
1194 """ | 1193 """ |
1195 cmd = self.params.get("mem_chk_cur_cmd") | 1194 cmd = self.params.get("mem_chk_cur_cmd") |
1196 return self.get_memory_size(cmd) | 1195 return self.get_memory_size(cmd) |
OLD | NEW |