From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga09.intel.com (mga09.intel.com [134.134.136.24]) by dpdk.org (Postfix) with ESMTP id 7F2E41B343 for ; Fri, 22 Dec 2017 09:09:51 +0100 (CET) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga006.fm.intel.com ([10.253.24.20]) by orsmga102.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 22 Dec 2017 00:09:50 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.45,439,1508828400"; d="scan'208";a="189213748" Received: from fmsmsx107.amr.corp.intel.com ([10.18.124.205]) by fmsmga006.fm.intel.com with ESMTP; 22 Dec 2017 00:09:49 -0800 Received: from fmsmsx153.amr.corp.intel.com (10.18.125.6) by fmsmsx107.amr.corp.intel.com (10.18.124.205) with Microsoft SMTP Server (TLS) id 14.3.319.2; Fri, 22 Dec 2017 00:09:49 -0800 Received: from shsmsx104.ccr.corp.intel.com (10.239.4.70) by FMSMSX153.amr.corp.intel.com (10.18.125.6) with Microsoft SMTP Server (TLS) id 14.3.319.2; Fri, 22 Dec 2017 00:09:49 -0800 Received: from shsmsx103.ccr.corp.intel.com ([169.254.4.213]) by SHSMSX104.ccr.corp.intel.com ([169.254.5.152]) with mapi id 14.03.0319.002; Fri, 22 Dec 2017 16:09:47 +0800 From: "Liu, Yong" To: Herbert Guan , "dts@dpdk.org" CC: "phil.yang@arm.com" , "jianbo.liu@arm.com" Thread-Topic: [dts] [PATCH] framework: enable AArch64 and add more options for libvirt Thread-Index: AQHTbYx31U2LqjVfPEiJwC3tO0OwQqNPA/7Q Date: Fri, 22 Dec 2017 08:09:46 +0000 Message-ID: <86228AFD5BCD8E4EBFD2B90117B5E81E62F3804E@SHSMSX103.ccr.corp.intel.com> References: <1512452777-3982-1-git-send-email-herbert.guan@arm.com> In-Reply-To: <1512452777-3982-1-git-send-email-herbert.guan@arm.com> Accept-Language: zh-CN, en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-titus-metadata-40: eyJDYXRlZ29yeUxhYmVscyI6IiIsIk1ldGFkYXRhIjp7Im5zIjoiaHR0cDpcL1wvd3d3LnRpdHVzLmNvbVwvbnNcL0ludGVsMyIsImlkIjoiNzJiMmM2MGItY2FmNy00OWU3LWJjY2UtMDJjODI1ZDc2Nzg1IiwicHJvcHMiOlt7Im4iOiJDVFBDbGFzc2lmaWNhdGlvbiIsInZhbHMiOlt7InZhbHVlIjoiQ1RQX0lDIn1dfV19LCJTdWJqZWN0TGFiZWxzIjpbXSwiVE1DVmVyc2lvbiI6IjE3LjIuNS4xOCIsIlRydXN0ZWRMYWJlbEhhc2giOiJnXC9Qd3UzWGdZQUd0aUhnTXpzNE52TmVUeUZpeWlXOUwraXQxNGQ4dExOQlV4eDRMK0NKUlIyMGdEVVJuSVpMciJ9 x-ctpclassification: CTP_IC dlp-product: dlpe-windows dlp-version: 11.0.0.116 dlp-reaction: no-action x-originating-ip: [10.239.127.40] Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Subject: Re: [dts] [PATCH] framework: enable AArch64 and add more options for libvirt 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: , X-List-Received-Date: Fri, 22 Dec 2017 08:09:52 -0000 Herbert, thanks for your patch. I'm not very clear about what is must for = AArch64 support and what is for enabling your environment. Please separate them in different functions.=20 Thanks, Marvin=20 > -----Original Message----- > From: dts [mailto:dts-bounces@dpdk.org] On Behalf Of Herbert Guan > Sent: Tuesday, December 05, 2017 1:46 PM > To: dts@dpdk.org > Cc: phil.yang@arm.com; jianbo.liu@arm.com; Herbert Guan > > Subject: [dts] [PATCH] framework: enable AArch64 and add more options for > libvirt >=20 > 1) Add the libvirt support on AArch64 platforms > 2) Add 'loader' and 'nvram' option support in 'os' section > 3) Add 'opt_bus', 'opt_dev' and 'opt_controller' option support in > 'disk' section. Change 'type' to 'opt_format' to get aligined > with option naming in qemu_kvm. > 4) Add serial 'serial_option' option support for serial console > 5) Add domain parsing in __parse_pci() > 6) Function add_vm_device() supports both VF (new) and PF devices now >=20 > Signed-off-by: Herbert Guan > --- > conf/vm_power_manager.cfg | 4 +- > framework/qemu_libvirt.py | 152 ++++++++++++++++++++++++++++++++++++++--= - > ----- > 2 files changed, 128 insertions(+), 28 deletions(-) > mode change 100644 =3D> 100755 conf/vm_power_manager.cfg > mode change 100644 =3D> 100755 framework/qemu_libvirt.py >=20 > diff --git a/conf/vm_power_manager.cfg b/conf/vm_power_manager.cfg > old mode 100644 > new mode 100755 > index 9c8f87a..7d5d9b6 > --- a/conf/vm_power_manager.cfg > +++ b/conf/vm_power_manager.cfg > @@ -7,7 +7,7 @@ > # size: 4096 > # disk > # file: absolute path to disk image > -# type: disk image format > +# opt_format: [ raw | qcow2 | ... ] #disk image format > # login > # user: user name to login into VM > # password: passwork to login into VM > @@ -25,7 +25,7 @@ cpu =3D > mem =3D > size=3D4096; > disk =3D > - file=3D/storage/vm-image/vm0.img,type=3Draw; > + file=3D/storage/vm-image/vm0.img,opt_format=3Draw; > login =3D > user=3Droot,password=3Dtester; > [vm1] > diff --git a/framework/qemu_libvirt.py b/framework/qemu_libvirt.py > old mode 100644 > new mode 100755 > index ed8e0e6..18dcd8b > --- a/framework/qemu_libvirt.py > +++ b/framework/qemu_libvirt.py > @@ -57,6 +57,7 @@ class LibvirtKvm(VirtBase): >=20 > # disk and pci device default index > self.diskindex =3D 'a' > + self.controllerindex =3D 0 > self.pciindex =3D 10 >=20 > # configure root element > @@ -82,7 +83,12 @@ class LibvirtKvm(VirtBase): >=20 > # set some default values for vm, > # if there is not the values of the specified options > - self.set_vm_default() > + arch =3D self.host_session.send_expect('uname -m', '# ') > + set_default_func =3D getattr(self, 'set_vm_default_' + arch) > + if callable(set_default_func): > + set_default_func() > + else: > + self.set_vm_default() I'm not sure how much is the difference between x86 and AArch64 platform. L= ook like somethings are common for example graphic and control interface. Could we separate arch related setting in separated function and keep those= common in another function? >=20 > def get_qemu_emulator(self): > """ > @@ -98,6 +104,13 @@ class LibvirtKvm(VirtBase): > """ > check and setup host virtual ability > """ > + arch =3D self.host_session.send_expect('uname -m', '# ') > + if arch =3D=3D 'aarch64': > + out =3D self.host_session.send_expect('service libvirtd stat= us', > "# ") > + if 'active (running)' not in out: > + return False > + return True > + Herbert, libvirt status has been checked in function has_virtual_ability wh= en initialize LibvirtKvm object.=20 Why do this check again? > out =3D self.host_session.send_expect('cat /proc/cpuinfo | grep > flags', > '# ') > rgx =3D re.search(' vmx ', out) > @@ -201,6 +214,47 @@ class LibvirtKvm(VirtBase): > ',name=3Dorg.qemu.guest_agent.0'}) > self.qga_sock_path =3D '/tmp/%s_qga0.sock' % self.vm_name >=20 > + def add_vm_os(self, **options): > + os =3D self.domain.find('os') > + if 'loader' in options.keys(): > + loader =3D ET.SubElement( > + os, 'loader', {'readonly': 'yes', 'type': 'pflash'}) > + loader.text =3D options['loader'] > + if 'nvram' in options.keys(): > + nvram =3D ET.SubElement(os, 'nvram') > + nvram.text =3D options['nvram'] > + Where this function is called?=20 > + > + def set_vm_default_aarch64(self): > + os =3D ET.SubElement(self.domain, 'os') > + type =3D ET.SubElement( > + os, 'type', {'arch': 'aarch64', 'machine': 'virt'}) > + type.text =3D 'hvm' > + ET.SubElement(os, 'boot', {'dev': 'hd'}) > + > + features =3D ET.SubElement(self.domain, 'features') > + ET.SubElement(features, 'acpi') > + ET.SubElement(features, 'gic', {'version': '3'}) > + > + ET.SubElement(self.domain, 'cpu', > + {'mode': 'host-passthrough', 'check': 'none'}) > + > + # qemu-kvm for emulator > + device =3D ET.SubElement(self.domain, 'devices') > + ET.SubElement(device, 'emulator').text =3D self.qemu_emulator > + > + # graphic device > + #ET.SubElement(device, 'graphics', { > + # 'type': 'vnc', 'port': '-1', 'autoport': 'yes'}) > + # qemu guest agent > + self.add_vm_qga(None) > + > + # add default control interface > + if not self.__default_nic: > + def_nic =3D {'type': 'nic', 'opt_hostfwd': ''} > + self.add_vm_net(**def_nic) > + self.__default_nic =3D True > + > def set_vm_default(self): > os =3D ET.SubElement(self.domain, 'os') > type =3D ET.SubElement( > @@ -273,17 +327,44 @@ class LibvirtKvm(VirtBase): > return False >=20 > ET.SubElement(disk, 'source', {'file': options['file']}) > - if 'type' not in options: > + if 'opt_format' not in options: > disk_type =3D 'raw' > else: > - disk_type =3D options['type'] > + disk_type =3D options['opt_format'] >=20 > ET.SubElement(disk, 'driver', {'name': 'qemu', 'type': disk_type= }) >=20 > + if 'opt_bus' not in options: > + bus =3D 'virtio' > + else: > + bus =3D options['opt_bus'] > + if 'opt_dev' not in options: > + dev =3D 'vd%c' % self.diskindex > + self.diskindex =3D chr(ord(self.diskindex) + 1) > + else: > + dev =3D options['opt_dev'] > ET.SubElement( > - disk, 'target', {'dev': 'vd%c' % self.diskindex, 'bus': > 'virtio'}) > + disk, 'target', {'dev': dev, 'bus': bus}) > + > + if 'opt_controller' in options: > + controller =3D ET.SubElement(devices, 'controller', > + {'type': bus, > + 'index': hex(self.controllerindex)[2:], > + 'model': options['opt_controller']}) > + self.controllerindex +=3D 1 > + ET.SubElement(controller, 'address', > + {'type': 'pci', 'domain': '0x0000', 'bus': > hex(self.pciindex), > + 'slot': '0x00', 'function': '0x00'}) > + self.pciindex +=3D 1 >=20 > - self.diskindex =3D chr(ord(self.diskindex) + 1) > + def add_vm_serial_port(self, **options): > + if 'enable' in options.keys(): > + if options['enable'].lower() =3D=3D 'yes': > + devices =3D self.domain.find('devices') > + serial =3D ET.SubElement(devices, 'serial', {'type': 'pt= y'}) > + ET.SubElement(serial, 'target', {'port': '0'}) > + console =3D ET.SubElement(devices, 'console', {'type': > 'pty'}) > + ET.SubElement(console, 'target', {'type': 'serial', > 'port': '0'}) >=20 In qemu kvm module, we are using unix domain socket for serial device. Can = you align to this? Please let device type should be configurable, we plan to add more types la= ter. > def add_vm_login(self, **options): > """ > @@ -305,14 +386,23 @@ class LibvirtKvm(VirtBase): > def __parse_pci(self, pci_address): > pci_regex =3D r"([0-9a-fA-F]{1,2}):([0-9a-fA-F]{1,2})" + \ > ".([0-9a-fA-F]{1,2})" > + pci_regex_domain =3D r"([0-9a-fA-F]{1,4}):([0-9a-fA-F]{1,2}):" += \ > + "([0-9a-fA-F]{1,2}).([0-9a-fA-F]{1,2})" > m =3D re.match(pci_regex, pci_address) > - if m is None: > - return None > - bus =3D m.group(1) > - slot =3D m.group(2) > - func =3D m.group(3) > - > - return (bus, slot, func) > + if m is not None: > + bus =3D m.group(1) > + slot =3D m.group(2) > + func =3D m.group(3) > + dom =3D '0' > + return (bus, slot, func, dom) > + m =3D re.match(pci_regex_domain, pci_address) > + if m is not None: > + bus =3D m.group(2) > + slot =3D m.group(3) > + func =3D m.group(4) > + dom =3D m.group(1) > + return (bus, slot, func, dom) > + return None >=20 > def add_vm_device(self, **options): > """ > @@ -325,35 +415,45 @@ class LibvirtKvm(VirtBase): > 'mode': 'subsystem', 'type': 'pci', > 'managed': 'yes'}) >=20 > - if 'pf_idx' not in options.keys(): > - print utils.RED("Missing device index for device option!!!") > - return False > - > - pf =3D int(options['pf_idx']) > - if pf > len(self.host_dut.ports_info): > - print utils.RED("PF device index over size!!!") > + if 'pf_idx' in options.keys(): > + pf =3D int(options['pf_idx']) > + if pf > len(self.host_dut.ports_info): > + print utils.RED("PF device index over size!!!") > + return False Previous check sentence is incorrect:) Should be "if pf >=3D len(self.host_= dut.ports_info):".=20 Most of suites are just using option "opt_host" to specify the pci address = of device. So I'm planning to remove pf_idx option, what's your idea for th= at? > + pci_addr =3D self.host_dut.ports_info[pf]['pci'] > + elif 'vf_idx' in options.keys(): > + vf =3D int(options['vf_idx']) > + if vf > len(self.host_dut.ports_info): > + print utils.RED("VF device index over size!!!") > + return False > + if 'vf_id' in options.keys(): > + vf_id =3D int(options['vf_id']) > + else: > + vf_id =3D 0 > + pci_addr =3D > self.host_dut.ports_info[vf]['sriov_vfs_pci'][vf_id] > + else: > + print utils.RED("Missing pf/vf device index for device > option!!!") > return False >=20 > - pci_addr =3D self.host_dut.ports_info[pf]['pci'] >=20 > pci =3D self.__parse_pci(pci_addr) > if pci is None: > return False > - bus, slot, func =3D pci > + bus, slot, func, dom =3D pci >=20 > source =3D ET.SubElement(hostdevice, 'source') > ET.SubElement(source, 'address', { > - 'domain': '0x0', 'bus': '0x%s' % bus, > + 'domain': '0x%s' % dom, 'bus': '0x%s' % bus, > 'slot': '0x%s' % slot, > 'function': '0x%s' % func}) > if 'guestpci' in options.keys(): > pci =3D self.__parse_pci(options['guestpci']) > if pci is None: > return False > - bus, slot, func =3D pci > + bus, slot, func, dom =3D pci > ET.SubElement(hostdevice, 'address', { > - 'type': 'pci', 'domain': '0x0', 'bus': '0x%s' = % > bus, > - 'slot': '0x%s' % slot, 'function': '0x%s' % > func}) > + 'type': 'pci', 'domain': '0x%s' % dom, 'bus': '0x%s' % > bus, > + 'slot': '0x%s' % slot, 'function': '0x%s' % func}) > # save host and guest pci address mapping > pci_map =3D {} > pci_map['hostpci'] =3D pci_addr > @@ -397,7 +497,7 @@ class LibvirtKvm(VirtBase): > pci =3D self.__parse_pci(options['opt_addr']) > if pci is None: > return False > - bus, slot, func =3D pci > + bus, slot, func, dom =3D pci > ET.SubElement(qemu, 'qemu:arg', > {'value': 'nic,model=3De1000,addr=3D0x%s' % sl= ot}) > else: > -- > 1.8.3.1