From owner-freebsd-virtualization@freebsd.org Wed Mar 18 04:06:00 2020 Return-Path: Delivered-To: freebsd-virtualization@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 12E0F27B872 for ; Wed, 18 Mar 2020 04:06:00 +0000 (UTC) (envelope-from wanpengqian@gmail.com) Received: from mail-qv1-xf2a.google.com (mail-qv1-xf2a.google.com [IPv6:2607:f8b0:4864:20::f2a]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (2048 bits) client-digest SHA256) (Client CN "smtp.gmail.com", Issuer "GTS CA 1O1" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 48hxKg0kRKz4f7Z for ; Wed, 18 Mar 2020 04:05:58 +0000 (UTC) (envelope-from wanpengqian@gmail.com) Received: by mail-qv1-xf2a.google.com with SMTP id cy12so6294292qvb.7 for ; Tue, 17 Mar 2020 21:05:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:from:date:message-id:subject:to; bh=Td9QaUtba5Rb8W/efKc3ylBCzI041eGd3Y+zlRlDM/g=; b=OBLhsOMPiMKlVqfYmTxKEn94RRPmjIs6Bl27BJo+YNtQXqyEzywjsGxu5X4QdNI1Eb BdUTfLEV1qKIBU4um+kGL8kDja8gumYUeo7mrk3qlLiM+ZvXLmFwroAuXdARvr5pz3oJ pOz/1O1FbCmxKGrUSw5XtaD68wCVFstYEVM5VkNpHnzpMNVqsbmzM6VsJtWCsRCvxilp 95Cc8EJB5wqO68pxMdxBHIakFa0FGulEFRavPAz8N4XCsBRvG5QEHCSki2FD5eW1+rq5 AruqUb7fehIV+fEL2zJCY5wI+38glAP8DKWlNdtYy4DkSLKHMJhzdIQLIRNqQ4CcVXLf UxAg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:from:date:message-id:subject:to; bh=Td9QaUtba5Rb8W/efKc3ylBCzI041eGd3Y+zlRlDM/g=; b=eRir6q5Lg5PRlnnOl0ahnBIokkiIZ01cm1NNWJ+02M64kLnC5bYTWDTO9zOy5IEGMf kDr6izf3LgIUr3uPhLtJ00NPWSmtnVQ47kQXC7zK5VYLWbcSHLTYAsjFWe2JmrEGuPAC AECmT7POGH7I8q8Mtvfm8wcAoOxXgDbNSb1NTrwXMltO8BM3PSMDkDY/5ZEIKBmx1rfv XbhNV2bovP3MD5eV7RP8ddXYQsRbVUwOh9gc2PMTju3uo4czYy5Oxnbmv++pcUmft1dn ZQkN9MGzUDp8IO+ijmULMZG+XeyMFalrn8PPgG0s4mApg/S10YRXwOIJA9yw9zLRh6V6 1q/Q== X-Gm-Message-State: ANhLgQ1KMyG4kC+NAdgmHhtKgJrvLqjpvDR7vq6EFu+yjtl9iH0xTAlr 0Qvsooh4ihM/9xuwlSFW0mB7JTcPO/y+RSraafb4MEguDYw= X-Google-Smtp-Source: ADFU+vsGMB7ej0RBeQKYOMfa5ngOGQMYU4IJUXZICwkb5CXgHX/xu1pzsb7iLX8aBM67hwkT0OMd97/EVfb7x6uPSfY= X-Received: by 2002:a0c:edc5:: with SMTP id i5mr2418942qvr.16.1584504357504; Tue, 17 Mar 2020 21:05:57 -0700 (PDT) MIME-Version: 1.0 From: Wanpeng Qian Date: Wed, 18 Mar 2020 13:05:40 +0900 Message-ID: Subject: bhyve: passthrough SMART info from host nvme controller To: FreeBSD virtualization Content-Type: text/plain; charset="UTF-8" X-Rspamd-Queue-Id: 48hxKg0kRKz4f7Z X-Spamd-Bar: -- Authentication-Results: mx1.freebsd.org; dkim=pass header.d=gmail.com header.s=20161025 header.b=OBLhsOMP; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (mx1.freebsd.org: domain of wanpengqian@gmail.com designates 2607:f8b0:4864:20::f2a as permitted sender) smtp.mailfrom=wanpengqian@gmail.com X-Spamd-Result: default: False [-3.00 / 15.00]; ARC_NA(0.00)[]; NEURAL_HAM_MEDIUM(-1.00)[-1.000,0]; R_DKIM_ALLOW(-0.20)[gmail.com:s=20161025]; FROM_HAS_DN(0.00)[]; R_SPF_ALLOW(-0.20)[+ip6:2607:f8b0:4000::/36]; FREEMAIL_FROM(0.00)[gmail.com]; MIME_GOOD(-0.10)[text/plain]; PREVIOUSLY_DELIVERED(0.00)[freebsd-virtualization@freebsd.org]; NEURAL_HAM_LONG(-1.00)[-1.000,0]; IP_SCORE_FREEMAIL(0.00)[]; RCPT_COUNT_ONE(0.00)[1]; IP_SCORE(0.00)[ip: (-5.56), ipnet: 2607:f8b0::/32(-1.85), asn: 15169(-1.65), country: US(-0.05)]; TO_DN_ALL(0.00)[]; DKIM_TRACE(0.00)[gmail.com:+]; DMARC_POLICY_ALLOW(-0.50)[gmail.com,none]; RCVD_IN_DNSWL_NONE(0.00)[a.2.f.0.0.0.0.0.0.0.0.0.0.0.0.0.0.2.0.0.4.6.8.4.0.b.8.f.7.0.6.2.list.dnswl.org : 127.0.5.0]; TO_MATCH_ENVRCPT_ALL(0.00)[]; FROM_EQ_ENVFROM(0.00)[]; MIME_TRACE(0.00)[0:+]; FREEMAIL_ENVFROM(0.00)[gmail.com]; ASN(0.00)[asn:15169, ipnet:2607:f8b0::/32, country:US]; RCVD_COUNT_TWO(0.00)[2]; RCVD_TLS_ALL(0.00)[]; DWL_DNSWL_NONE(0.00)[gmail.com.dwl.dnswl.org : 127.0.5.0] X-BeenThere: freebsd-virtualization@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "Discussion of various virtualization techniques FreeBSD supports." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 18 Mar 2020 04:06:00 -0000 Hello all. I have an idea about provide SMART of nvme controller. Currently bhyve's nvme controller didn't provide any SMART information. if we provide fake SMART, that is meaningless. I am thinking we can read the host nvme controller SMART and provide that to guest. such as nvme,disk1.img,maxq=16,qsz=8,ioslots=1,sectsz=512,ser=QNVME778,smart=nvme0 I have done some draft code. and it work. here is the output of nvmecontrol identify and logpage. root@smart:~ # nvmecontrol identify nvme0 Controller Capabilities/Features ================================ Vendor ID: fb5d Subsystem Vendor ID: 0000 Serial Number: QNVME778 Model Number: bhyve-NVMe Firmware Version: 1.0 Recommended Arb Burst: 4 IEEE OUI Identifier: 58 9c fc Multi-Path I/O Capabilities: Not Supported Max Data Transfer Size: 2097152 bytes Controller ID: 0x0000 Version: 1.3.0 Admin Command Set Attributes ============================ Security Send/Receive: Not Supported Format NVM: Supported Firmware Activate/Download: Not Supported Namespace Managment: Not Supported Device Self-test: Not Supported Directives: Not Supported NVMe-MI Send/Receive: Not Supported Virtualization Management: Not Supported Doorbell Buffer Config: Not Supported Get LBA Status: Not Supported Sanitize: Not Supported Abort Command Limit: 3 Async Event Request Limit: 5 Number of Firmware Slots: N/A Firmware Slot 1 Read-Only: N/A Per-Namespace SMART Log: No Error Log Page Entries: 1 Number of Power States: 2 Total NVM Capacity: 0 bytes Unallocated NVM Capacity: 0 bytes NVM Command Set Attributes ========================== Submission Queue Entry Size Max: 64 Min: 64 Completion Queue Entry Size Max: 16 Min: 16 Number of Namespaces: 1 Compare Command: Not Supported Write Uncorrectable Command: Not Supported Dataset Management Command: Not Supported Write Zeroes Command: Not Supported Save Features: Not Supported Reservations: Not Supported Timestamp feature: Not Supported Verify feature: Not Supported Fused Operation Support: Not Supported Format NVM Attributes: All-NVM Erase, All-NVM Format Volatile Write Cache: Not Present NVM Subsystem Name: root@smart:~ # nvmecontrol logpage -p 2 nvme0 SMART/Health Information Log ============================ Critical Warning State: 0x00 Available spare: 0 Temperature: 0 Device reliability: 0 Read only: 0 Volatile memory backup: 0 Temperature: 309 K, 35.85 C, 96.53 F Available spare: 100 Available spare threshold: 10 Percentage used: 0 Data units (512,000 byte) read: 173065 Data units written: 9381970 Host read commands: 4123220 Host write commands: 846568092 Controller busy time (minutes): 948 Power cycles: 918 Power on hours: 2631 Unsafe shutdowns: 812 Media errors: 0 No. error info log entries: 2546 Warning Temp Composite Time: 75 Error Temp Composite Time: 58 Temperature 1 Transition Count: 0 Temperature 2 Transition Count: 0 Total Time For Temperature 1: 0 Total Time For Temperature 2: 0 But currently bhyve has Capsicum capability, I cannot open /dev/nvme0 within pci_nvme.c without extra code. (currently I just disable the Capsicum capability) any feedback?