From owner-svn-src-stable@FreeBSD.ORG Fri Mar 27 08:54:57 2015 Return-Path: Delivered-To: svn-src-stable@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id 2766221B; Fri, 27 Mar 2015 08:54:57 +0000 (UTC) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id EC46FC49; Fri, 27 Mar 2015 08:54:56 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.9/8.14.9) with ESMTP id t2R8sutn026109; Fri, 27 Mar 2015 08:54:56 GMT (envelope-from mav@FreeBSD.org) Received: (from mav@localhost) by svn.freebsd.org (8.14.9/8.14.9/Submit) id t2R8suRp026108; Fri, 27 Mar 2015 08:54:56 GMT (envelope-from mav@FreeBSD.org) Message-Id: <201503270854.t2R8suRp026108@svn.freebsd.org> X-Authentication-Warning: svn.freebsd.org: mav set sender to mav@FreeBSD.org using -f From: Alexander Motin Date: Fri, 27 Mar 2015 08:54:56 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-10@freebsd.org Subject: svn commit: r280745 - stable/10/usr.sbin/bhyve X-SVN-Group: stable-10 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.18-1 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 27 Mar 2015 08:54:57 -0000 Author: mav Date: Fri Mar 27 08:54:55 2015 New Revision: 280745 URL: https://svnweb.freebsd.org/changeset/base/280745 Log: MFC r280040: Give AHCI disk serial based on backing file path same as for virtio block. It is still not good that they may intersect on different hosts, but that is better then intersecting on the same host. Modified: stable/10/usr.sbin/bhyve/pci_ahci.c Directory Properties: stable/10/ (props changed) Modified: stable/10/usr.sbin/bhyve/pci_ahci.c ============================================================================== --- stable/10/usr.sbin/bhyve/pci_ahci.c Fri Mar 27 08:53:59 2015 (r280744) +++ stable/10/usr.sbin/bhyve/pci_ahci.c Fri Mar 27 08:54:55 2015 (r280745) @@ -50,6 +50,7 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include #include "bhyverun.h" #include "pci_emul.h" @@ -131,6 +132,7 @@ struct ahci_port { struct pci_ahci_softc *pr_sc; uint8_t *cmd_lst; uint8_t *rfis; + char ident[20 + 1]; int atapi; int reset; int mult_sectors; @@ -855,8 +857,7 @@ handle_identify(struct ahci_port *p, int buf[1] = cyl; buf[3] = heads; buf[6] = sech; - /* TODO emulate different serial? */ - ata_string((uint8_t *)(buf+10), "123456", 20); + ata_string((uint8_t *)(buf+10), p->ident, 20); ata_string((uint8_t *)(buf+23), "001", 8); ata_string((uint8_t *)(buf+27), "BHYVE SATA DISK", 40); buf[47] = (0x8000 | 128); @@ -946,8 +947,7 @@ handle_atapi_identify(struct ahci_port * memset(buf, 0, sizeof(buf)); buf[0] = (2 << 14 | 5 << 8 | 1 << 7 | 2 << 5); - /* TODO emulate different serial? */ - ata_string((uint8_t *)(buf+10), "123456", 20); + ata_string((uint8_t *)(buf+10), p->ident, 20); ata_string((uint8_t *)(buf+23), "001", 8); ata_string((uint8_t *)(buf+27), "BHYVE SATA DVD ROM", 40); buf[49] = (1 << 9 | 1 << 8); @@ -2167,6 +2167,8 @@ pci_ahci_init(struct vmctx *ctx, struct struct blockif_ctxt *bctxt; struct pci_ahci_softc *sc; int ret, slots; + MD5_CTX mdctx; + u_char digest[16]; ret = 0; @@ -2204,6 +2206,16 @@ pci_ahci_init(struct vmctx *ctx, struct sc->port[0].pr_sc = sc; /* + * Create an identifier for the backing file. Use parts of the + * md5 sum of the filename + */ + MD5Init(&mdctx); + MD5Update(&mdctx, opts, strlen(opts)); + MD5Final(digest, &mdctx); + sprintf(sc->port[0].ident, "BHYVE-%02X%02X-%02X%02X-%02X%02X", + digest[0], digest[1], digest[2], digest[3], digest[4], digest[5]); + + /* * Allocate blockif request structures and add them * to the free list */