From 906a8c38d57cb8554950364a3148057747a09617 Mon Sep 17 00:00:00 2001 From: Jason Wang Date: Mon, 21 Feb 2011 12:33:56 +0000 Subject: [PATCH] KVM test: nic_hotplug: Add romfile support This patch allows to test hotplug a nic with dedicated rom file. Signed-off-by: Jason Wang --- kvm/tests/nic_hotplug.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/kvm/tests/nic_hotplug.py b/kvm/tests/nic_hotplug.py index 50a3ce9e4..2946396ef 100644 --- a/kvm/tests/nic_hotplug.py +++ b/kvm/tests/nic_hotplug.py @@ -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") @@ -57,7 +58,7 @@ 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 @@ -65,6 +66,7 @@ def nic_add(vm, model, netdev_id, mac): @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": @@ -72,6 +74,8 @@ def nic_add(vm, model, netdev_id, mac): 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) @@ -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 &" %