Skip to content

Commit

Permalink
KVM test: nic_hotplug: Add romfile support
Browse files Browse the repository at this point in the history
This patch allows to test hotplug a nic with dedicated rom file.

Signed-off-by: Jason Wang <[email protected]>
  • Loading branch information
jasowang committed Feb 21, 2011
1 parent 8509ac4 commit 906a8c3
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions kvm/tests/nic_hotplug.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ def run_nic_hotplug(test, params, env):
guest_delay = int(params.get("guest_delay", 20))
session_serial = kvm_test_utils.wait_for_login(vm, timeout=timeout,
serial=True)
romfile = params.get("romfile")

# Modprobe the module if specified in config file
module = params.get("modprobe_module")
Expand Down Expand Up @@ -57,21 +58,24 @@ def netdev_del(vm, n_id):
logging.error(network)
raise error.TestError("Fail to remove netdev %s" % n_id)

def nic_add(vm, model, netdev_id, mac):
def nic_add(vm, model, netdev_id, mac, rom=None):
"""
Add a nic to virtual machine
@vm: VM object
@model: nic model
@netdev_id: id of netdev
@mac: Mac address of new nic
@rom: Rom file
"""
nic_id = kvm_utils.generate_random_id()
if model == "virtio":
model = "virtio-net-pci"
device_add_cmd = "device_add %s,netdev=%s,mac=%s,id=%s" % (model,
netdev_id,
mac, nic_id)
if rom:
device_add_cmd += ",romfile=%s" % rom
logging.info("Adding nic through %s", device_add_cmd)
vm.monitor.cmd(device_add_cmd)

Expand Down Expand Up @@ -108,7 +112,7 @@ def nic_del(vm, nic_id, wait=True):
if not mac:
mac = "00:00:02:00:00:02"
netdev_id = netdev_add(vm)
device_id = nic_add(vm, "virtio", netdev_id, mac)
device_id = nic_add(vm, "virtio", netdev_id, mac, romfile)

if "Win" not in params.get("guest_name", ""):
session_serial.sendline("dhclient %s &" %
Expand Down

0 comments on commit 906a8c3

Please sign in to comment.