KVM test: kvm_vm.py: style corrections in add_nic() and add_net()
PATCH 1/1 KVM test: kvm_vm.py: style corrections in add_nic() and add_net()
Signed-off-by Michael Goldish <[email protected]>
--- client/tests/kvm/kvm_vm.py | 25 +++++++++++-------------- 1 files changed, 11 insertions(+), 14 deletions(-)
client/tests/kvm/kvm_vm.py +11 -14
@@ -236,25 +236,22 @@ class VM: def add_nic(help, vlan, model=None, mac=None, netdev_id=None, nic_extra_params=None): + if has_option(help, "netdev"): + netdev_vlan_str = ",netdev=%s" % netdev_id + else: + netdev_vlan_str = ",vlan=%d" % vlan if has_option(help, "device"): - if model == "virtio": - model="virtio-net-pci" if not model: - model= "rtl8139" - cmd = " -device %s" % model + model = "rtl8139" + elif model == "virtio": + model = "virtio-net-pci" + cmd = " -device %s" % model + netdev_vlan_str if mac: - cmd += ",mac=%s" % mac - if has_option(help, "netdev"): - cmd += ",netdev=%s" % netdev_id - else: - cmd += "vlan=%d," % vlan + cmd += ",mac='%s'" % mac if nic_extra_params: cmd += ",%s" % nic_extra_params else: - if has_option(help, "netdev"): - cmd = " -net nic,netdev=%s" % netdev_id - else: - cmd = " -net nic,vlan=%d" % vlan + cmd = " -net nic" + netdev_vlan_str if model: cmd += ",model=%s" % model if mac:
@@ -267,7 +264,7 @@ class VM: if has_option(help, "netdev"): cmd = " -netdev %s,id=%s" % (mode, netdev_id) if vhost: - cmd +=",vhost=on" + cmd += ",vhost=on" else: cmd = " -net %s,vlan=%d" % (mode, vlan) if mode == "tap":
Signature · 1 line
1.5.5.6
PATCH 1/1 KVM test: VM.create(): fix netdev_id generation
Clear the list of netdev IDs before generating new ones.
Signed-off-by Michael Goldish <[email protected]>
--- client/tests/kvm/kvm_vm.py | 2 ++ 1 files changed, 2 insertions(+), 0 deletions(-)
client/tests/kvm/kvm_vm.py +2 -0
@@ -581,6 +581,8 @@ class VM: guest_port = int(redir_params.get("guest_port")) self.redirs[guest_port] = host_ports[i] + # Generate netdev IDs for all NICs + self.netdev_id = [] for nic in kvm_utils.get_sub_dict_names(params, "nics"): self.netdev_id.append(kvm_utils.generate_random_id())
Signature · 1 line
1.5.5.6
PATCH 1/1 KVM test: kvm_subprocess: add aliases for cmd_* functions for backward compatibility
Add aliases to maintain compatibility with tests that use the long names.
Signed-off-by Michael Goldish <[email protected]>
--- client/tests/kvm/kvm_subprocess.py | 25 +++++++++++++++++++++++++ 1 files changed, 25 insertions(+), 0 deletions(-)
client/tests/kvm/kvm_subprocess.py +25 -0
@@ -1323,3 +1323,28 @@ class ShellSession(Expect): if s != 0: raise ShellCmdError(cmd, s, o) return o + + + def get_command_output(self, cmd, timeout=30.0, internal_timeout=None, + print_func=None): + """ + Alias for cmd_output() for backward compatibility. + """ + return self.cmd_output(cmd, timeout, internal_timeout, print_func) + + + def get_command_status_output(self, cmd, timeout=30.0, + internal_timeout=None, print_func=None): + """ + Alias for cmd_status_output() for backward compatibility. + """ + return self.cmd_status_output(cmd, timeout, internal_timeout, + print_func) + + + def get_command_status(self, cmd, timeout=30.0, internal_timeout=None, + print_func=None): + """ + Alias for cmd_status() for backward compatibility. + """ + return self.cmd_status(cmd, timeout, internal_timeout, print_func)
Signature · 1 line
1.5.5.6