From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id 8F21CA0487 for ; Tue, 30 Jul 2019 08:44:04 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 52D851BF23; Tue, 30 Jul 2019 08:44:04 +0200 (CEST) Received: from mga14.intel.com (mga14.intel.com [192.55.52.115]) by dpdk.org (Postfix) with ESMTP id 6BCB31BEF8 for ; Tue, 30 Jul 2019 08:44:02 +0200 (CEST) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga008.jf.intel.com ([10.7.209.65]) by fmsmga103.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 29 Jul 2019 23:44:00 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.64,325,1559545200"; d="scan'208";a="165753894" Received: from dpdk-lihong-ub1604.sh.intel.com ([10.67.119.68]) by orsmga008.jf.intel.com with ESMTP; 29 Jul 2019 23:43:59 -0700 From: lihong To: dts@dpdk.org Cc: lihong Date: Tue, 30 Jul 2019 07:20:57 +0800 Message-Id: <1564442457-15344-1-git-send-email-lihongx.ma@intel.com> X-Mailer: git-send-email 2.7.4 Subject: [dts] [PATCH V1] framework/qemu_kvm: use -device instead of -net nic param when start qemu X-BeenThere: dts@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: test suite reviews and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dts-bounces@dpdk.org Sender: "dts" After qemu3.0, 'vlan' is deprecated, use 'netdev' instead. use '-device devtype,netdev=str' instead of -net nic use '-netdev option' instead of -net user/tap Signed-off-by: lihong --- framework/qemu_kvm.py | 75 ++++++++++++++++++--------------------------------- 1 file changed, 26 insertions(+), 49 deletions(-) diff --git a/framework/qemu_kvm.py b/framework/qemu_kvm.py index c7d4041..c425f41 100644 --- a/framework/qemu_kvm.py +++ b/framework/qemu_kvm.py @@ -146,11 +146,12 @@ class QEMUKvm(VirtBase): self.set_vm_daemon() self.set_vm_monitor() + self.nic_num = 1 if not self.__default_nic: # add default control interface - def_nic = {'type': 'nic', 'opt_vlan': '0', 'opt_addr': '1f'} + def_nic = {'type': 'nic'} self.set_vm_net(**def_nic) - def_net = {'type': 'user', 'opt_vlan': '0'} + def_net = {'type': 'user'} self.set_vm_net(**def_net) self.__default_nic = True @@ -469,8 +470,6 @@ class QEMUKvm(VirtBase): note:the sub-option will be decided according to the net type. """ if 'type' in options.keys(): - if 'opt_vlan' not in options.keys(): - options['opt_vlan'] = '0' if options['type'] == 'nic': self.__add_vm_net_nic(**options) if options['type'] == 'user': @@ -511,32 +510,11 @@ class QEMUKvm(VirtBase): def __add_vm_net_nic(self, **options): """ type: nic - opt_vlan: 0 - note: Default is 0. - opt_macaddr: 00:00:00:00:01:01 - note: if creating a nic, it`s better to specify a MAC, - else it will get a random number. opt_model:["e1000" | "virtio" | "i82551" | ...] note: Default is e1000. - opt_name: 'nic1' - opt_addr: '' - note: PCI cards only. - opt_vectors: - note: This option currently only affects virtio cards. """ - net_boot_line = '-net nic' + net_boot_line = '-device ' separator = ',' - if 'opt_vlan' in options.keys() and \ - options['opt_vlan']: - net_boot_line += separator + 'vlan=%s' % options['opt_vlan'] - - # add MAC info - if 'opt_macaddr' in options.keys() and \ - options['opt_macaddr']: - mac = options['opt_macaddr'] - else: - mac = self.generate_unique_mac() - net_boot_line += separator + 'macaddr=%s' % mac if 'opt_model' in options.keys() and \ options['opt_model']: @@ -544,17 +522,14 @@ class QEMUKvm(VirtBase): else: model = 'e1000' self.nic_model = model - net_boot_line += separator + 'model=%s' % model + net_boot_line += model - if 'opt_name' in options.keys() and \ - options['opt_name']: - net_boot_line += separator + 'name=%s' % options['opt_name'] - if 'opt_addr' in options.keys() and \ - options['opt_addr']: - net_boot_line += separator + 'addr=%s' % options['opt_addr'] - if 'opt_vectors' in options.keys() and \ - options['opt_vectors']: - net_boot_line += separator + 'vectors=%s' % options['opt_vectors'] + netdev_id = self.nic_num + if self.nic_num % 2 == 0: + netdev_id = self.nic_num - 1 + netdev = "netdev=nttsip%d " % netdev_id + self.nic_num = self.nic_num + 1 + net_boot_line += separator + netdev if self.__string_has_multi_fields(net_boot_line, separator): self.__add_boot_line(net_boot_line) @@ -562,15 +537,16 @@ class QEMUKvm(VirtBase): def __add_vm_net_user(self, **options): """ type: user - opt_vlan: 0 - note: default is 0. opt_hostfwd: [tcp|udp]:[hostaddr]:hostport-[guestaddr]:guestport """ - net_boot_line = '-net user' + net_boot_line = '-netdev user' separator = ',' - if 'opt_vlan' in options.keys() and \ - options['opt_vlan']: - net_boot_line += separator + 'vlan=%s' % options['opt_vlan'] + netdev_id = self.nic_num + if self.nic_num % 2 == 0: + netdev_id = self.nic_num - 1 + self.nic_num = self.nic_num + 1 + netdev = "id=nttsip%d" % netdev_id + net_boot_line += separator + netdev if 'opt_hostfwd' in options.keys() and \ options['opt_hostfwd']: self.__check_net_user_opt_hostfwd(options['opt_hostfwd']) @@ -651,8 +627,6 @@ class QEMUKvm(VirtBase): def __add_vm_net_tap(self, **options): """ type: tap - opt_vlan: 0 - note: default is 0. opt_br: br0 note: if choosing tap, need to specify bridge name, else it will be br0. @@ -661,9 +635,16 @@ class QEMUKvm(VirtBase): opt_downscript: QEMU_IFDOWN_PATH note: if not specified, default is self.QEMU_IFDOWN_PATH. """ - net_boot_line = '-net tap' + net_boot_line = '-netdev tap' separator = ',' + netdev_id = self.nic_num + if self.nic_num % 2 == 0: + netdev_id = self.nic_num - 1 + self.nic_num = self.nic_num + 1 + netdev = "id=nttsip%d" % netdev_id + net_boot_line += separator + netdev + # add bridge info if 'opt_br' in options.keys() and \ options['opt_br']: @@ -672,10 +653,6 @@ class QEMUKvm(VirtBase): bridge = self.DEFAULT_BRIDGE self.__generate_net_config_script(str(bridge)) - if 'opt_vlan' in options.keys() and \ - options['opt_vlan']: - net_boot_line += separator + 'vlan=%s' % options['opt_vlan'] - # add network configure script path if 'opt_script' in options.keys() and \ options['opt_script']: -- 2.7.4