Page Menu
Home
FreeBSD
Search
Configure Global Search
Log In
Files
F107176174
D31983.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Flag For Later
Award Token
Size
2 KB
Referenced Files
None
Subscribers
None
D31983.diff
View Options
diff --git a/usr.sbin/bhyve/bhyve_config.5 b/usr.sbin/bhyve/bhyve_config.5
--- a/usr.sbin/bhyve/bhyve_config.5
+++ b/usr.sbin/bhyve/bhyve_config.5
@@ -23,7 +23,7 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.Dd April 20, 2021
+.Dd September 17, 2021
.Dt BHYVE_CONFIG 5
.Os
.Sh NAME
@@ -514,6 +514,16 @@
.It Va ro Ta bool Ta false Ta
If true, the guest filesystem is read-only.
.El
+.Ss VirtIO Block Device Settings
+In addition to the block device settings described above, each
+VirtIO block device supports the following settings:
+.Bl -column "model" "integer" "generated"
+.It Sy Name Ta Sy Format Ta Sy Default Ta Sy Description
+.It Va ser Ta string Ta generated Ta
+Serial number of up to twenty characters.
+A default serial number is generated using a hash of the backing
+store's pathname.
+.El
.Ss VirtIO Console Device Settings
Each VirtIO Console device contains one or more console ports.
Each port stores its settings in a node named
diff --git a/usr.sbin/bhyve/pci_virtio_block.c b/usr.sbin/bhyve/pci_virtio_block.c
--- a/usr.sbin/bhyve/pci_virtio_block.c
+++ b/usr.sbin/bhyve/pci_virtio_block.c
@@ -453,7 +453,7 @@
{
char bident[sizeof("XX:X:X")];
struct blockif_ctxt *bctxt;
- const char *path;
+ const char *path, *serial;
MD5_CTX mdctx;
u_char digest[16];
struct pci_vtblk_softc *sc;
@@ -498,16 +498,23 @@
/* sc->vbsc_vq.vq_notify = we have no per-queue notify */
/*
- * Create an identifier for the backing file. Use parts of the
- * md5 sum of the filename
+ * If an explicit identifier is not given, create an
+ * identifier using parts of the md5 sum of the filename.
*/
- path = get_config_value_node(nvl, "path");
- MD5Init(&mdctx);
- MD5Update(&mdctx, path, strlen(path));
- MD5Final(digest, &mdctx);
- snprintf(sc->vbsc_ident, VTBLK_BLK_ID_BYTES,
- "BHYVE-%02X%02X-%02X%02X-%02X%02X",
- digest[0], digest[1], digest[2], digest[3], digest[4], digest[5]);
+ bzero(sc->vbsc_ident, VTBLK_BLK_ID_BYTES);
+ if ((serial = get_config_value_node(nvl, "serial")) != NULL ||
+ (serial = get_config_value_node(nvl, "ser")) != NULL) {
+ strlcpy(sc->vbsc_ident, serial, VTBLK_BLK_ID_BYTES);
+ } else {
+ path = get_config_value_node(nvl, "path");
+ MD5Init(&mdctx);
+ MD5Update(&mdctx, path, strlen(path));
+ MD5Final(digest, &mdctx);
+ snprintf(sc->vbsc_ident, VTBLK_BLK_ID_BYTES,
+ "BHYVE-%02X%02X-%02X%02X-%02X%02X",
+ digest[0], digest[1], digest[2], digest[3], digest[4],
+ digest[5]);
+ }
/* setup virtio block config space */
sc->vbsc_cfg.vbc_capacity = size / VTBLK_BSIZE; /* 512-byte units */
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Sun, Jan 12, 6:49 AM (21 h, 11 s)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
15763038
Default Alt Text
D31983.diff (2 KB)
Attached To
Mode
D31983: bhyve: Support setting the disk serial number for VirtIO block devices.
Attached
Detach File
Event Timeline
Log In to Comment