git: b0bd185dc3f0 - stable/13 - bhyveload: open guest boot disk image O_RDWR

From: John Baldwin <jhb_at_FreeBSD.org>
Date: Thu, 26 Jan 2023 22:35:12 UTC
The branch stable/13 has been updated by jhb:

URL: https://cgit.FreeBSD.org/src/commit/?id=b0bd185dc3f0e90d4f9d3cd6c6bb9487af282474

commit b0bd185dc3f0e90d4f9d3cd6c6bb9487af282474
Author:     Robert Wing <rew@FreeBSD.org>
AuthorDate: 2022-12-05 17:22:45 +0000
Commit:     John Baldwin <jhb@FreeBSD.org>
CommitDate: 2023-01-26 22:29:36 +0000

    bhyveload: open guest boot disk image O_RDWR
    
    When a boot environment has been booted via the bootonce feature,
    userboot clears the bootonce value from an nvlist but fails to write the
    updated nvlist back to disk.
    
    The failure occurs because bhyveload opens the guest boot disk image
    O_RDONLY, fix this by opening it O_RDWR.
    
    Reviewed by:    imp, markj, jhb
    Differential Revision:  https://reviews.freebsd.org/D37274
    
    (cherry picked from commit 5a023bd2a53a7279b126ae6bf949560c6342b57a)
---
 usr.sbin/bhyveload/bhyveload.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/usr.sbin/bhyveload/bhyveload.c b/usr.sbin/bhyveload/bhyveload.c
index db7d995f2466..1a24b5f0044a 100644
--- a/usr.sbin/bhyveload/bhyveload.c
+++ b/usr.sbin/bhyveload/bhyveload.c
@@ -690,7 +690,7 @@ disk_open(char *path)
 	if (ndisks >= NDISKS)
 		return (ERANGE);
 
-	fd = open(path, O_RDONLY);
+	fd = open(path, O_RDWR);
 	if (fd < 0)
 		return (errno);