[Autotest] [KVM-AUTOTEST PATCH 11/28] KVM test: make_qemu_command(): catch IndexError when accessing self.netdev_id

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Michael Goldish writes:
 > make_qemu_command() is sometimes called to see if a VM needs to be restarted
 > using a different qemu command line.  When it's called with more NICs than the
 > VM currently has, accessing self.netdev_id can raise an IndexError.
 > 
 > Signed-off-by: Michael Goldish <mgoldish@xxxxxxxxxx>
 > ---
 >  client/tests/kvm/kvm_vm.py |   12 +++++++-----
 >  1 files changed, 7 insertions(+), 5 deletions(-)
 > 
 > diff --git a/client/tests/kvm/kvm_vm.py b/client/tests/kvm/kvm_vm.py
 > index 6aa8eb4..aeb7448 100755
 > --- a/client/tests/kvm/kvm_vm.py
 > +++ b/client/tests/kvm/kvm_vm.py
 > @@ -402,11 +402,14 @@ class VM:
 >          vlan = 0
 >          for nic_name in kvm_utils.get_sub_dict_names(params, "nics"):
 >              nic_params = kvm_utils.get_sub_dict(params, nic_name)
 > +            try:
 > +                netdev_id = self.netdev_id[vlan]
 > +            except IndexError:
 > +                netdev_id = None
 >              # Handle the '-net nic' part
 >              mac = self.get_mac_address(vlan)
 >              qemu_cmd += add_nic(help, vlan, nic_params.get("nic_model"), mac,
 > -                                self.netdev_id[vlan],
 > -                                nic_params.get("nic_extra_params"))
 > +                                netdev_id, nic_params.get("nic_extra_params"))
 >              # Handle the '-net tap' or '-net user' part
 >              script = nic_params.get("nic_script")
 >              downscript = nic_params.get("nic_downscript")
 > @@ -420,9 +423,8 @@ class VM:
 >              qemu_cmd += add_net(help, vlan, nic_params.get("nic_mode", "user"),
 >                                  self.get_ifname(vlan),
 >                                  script, downscript, tftp,
 > -                                nic_params.get("bootp"), redirs,
 > -                                self.netdev_id[vlan],
 > -                                nic_params.get("netdev_extra_params"))
 > +                                nic_params.get("bootp"), redirs, netdev_id,
 > +                                nic_params.get("vhost") == "yes")

Why drop netdev_extra_params here, we've used it to enable vhost. And it seems
the bootp is useless here as we've already used "-kernel" and "-initrd" to do
the unattended installation.

 >              # Proceed to next NIC
 >              vlan += 1
 >  
 > -- 
 > 1.7.3.3
 > 
 > _______________________________________________
 > Autotest mailing list
 > Autotest@xxxxxxxxxxxxxxx
 > http://test.kernel.org/cgi-bin/mailman/listinfo/autotest
--
To unsubscribe from this list: send the line "unsubscribe kvm" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [KVM ARM]     [KVM ia64]     [KVM ppc]     [Virtualization Tools]     [Spice Development]     [Libvirt]     [Libvirt Users]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite Questions]     [Linux Kernel]     [Linux SCSI]     [XFree86]
  Powered by Linux