git: b10d65a420f0 - main - bhyve: rename 'user_dev' with 'devices'

From: Corvin Köhne <corvink_at_FreeBSD.org>
Date: Mon, 19 Jun 2023 05:57:59 UTC
The branch main has been updated by corvink:

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

commit b10d65a420f068bccf6aaf2942157a5347211dc5
Author:     Vitaliy Gusev <gusev.vitaliy@gmail.com>
AuthorDate: 2023-05-15 14:28:14 +0000
Commit:     Corvin Köhne <corvink@FreeBSD.org>
CommitDate: 2023-06-19 05:57:01 +0000

    bhyve: rename 'user_dev' with 'devices'
    
    Bhyve don't use 'user' specifier for emulated devices. And
    using 'user' adds duality.
    
    Reviewed by:            corvink, rew
    MFC after:              1 week
    Sponsored by:           vStack
    Differential Revision:  https://reviews.freebsd.org/D40106
---
 usr.sbin/bhyve/bhyverun.c |  6 +++---
 usr.sbin/bhyve/snapshot.c | 23 +++++++++++------------
 usr.sbin/bhyve/snapshot.h |  6 +++---
 3 files changed, 17 insertions(+), 18 deletions(-)

diff --git a/usr.sbin/bhyve/bhyverun.c b/usr.sbin/bhyve/bhyverun.c
index 052657a50dbf..5ced5df0b4cb 100644
--- a/usr.sbin/bhyve/bhyverun.c
+++ b/usr.sbin/bhyve/bhyverun.c
@@ -1512,7 +1512,7 @@ main(int argc, char *argv[])
 #ifdef BHYVE_SNAPSHOT
 	if (restore_file != NULL) {
 		fprintf(stdout, "Pausing pci devs...\r\n");
-		if (vm_pause_user_devs() != 0) {
+		if (vm_pause_devices() != 0) {
 			fprintf(stderr, "Failed to pause PCI device state.\n");
 			exit(1);
 		}
@@ -1524,7 +1524,7 @@ main(int argc, char *argv[])
 		}
 
 		fprintf(stdout, "Restoring pci devs...\r\n");
-		if (vm_restore_user_devs(&rstate) != 0) {
+		if (vm_restore_devices(&rstate) != 0) {
 			fprintf(stderr, "Failed to restore PCI device state.\n");
 			exit(1);
 		}
@@ -1536,7 +1536,7 @@ main(int argc, char *argv[])
 		}
 
 		fprintf(stdout, "Resuming pci devs...\r\n");
-		if (vm_resume_user_devs() != 0) {
+		if (vm_resume_devices() != 0) {
 			fprintf(stderr, "Failed to resume PCI device state.\n");
 			exit(1);
 		}
diff --git a/usr.sbin/bhyve/snapshot.c b/usr.sbin/bhyve/snapshot.c
index dfe341c598b8..f7bff85e3361 100644
--- a/usr.sbin/bhyve/snapshot.c
+++ b/usr.sbin/bhyve/snapshot.c
@@ -856,7 +856,7 @@ vm_restore_kern_structs(struct vmctx *ctx, struct restore_state *rstate)
 }
 
 static int
-vm_restore_user_dev(struct restore_state *rstate,
+vm_restore_device(struct restore_state *rstate,
 		    const struct vm_snapshot_dev_info *info)
 {
 	void *dev_ptr;
@@ -901,15 +901,14 @@ vm_restore_user_dev(struct restore_state *rstate,
 	return (0);
 }
 
-
 int
-vm_restore_user_devs(struct restore_state *rstate)
+vm_restore_devices(struct restore_state *rstate)
 {
 	size_t i;
 	int ret;
 
 	for (i = 0; i < nitems(snapshot_devs); i++) {
-		ret = vm_restore_user_dev(rstate, &snapshot_devs[i]);
+		ret = vm_restore_device(rstate, &snapshot_devs[i]);
 		if (ret != 0)
 			return (ret);
 	}
@@ -918,7 +917,7 @@ vm_restore_user_devs(struct restore_state *rstate)
 }
 
 int
-vm_pause_user_devs(void)
+vm_pause_devices(void)
 {
 	const struct vm_snapshot_dev_info *info;
 	size_t i;
@@ -938,7 +937,7 @@ vm_pause_user_devs(void)
 }
 
 int
-vm_resume_user_devs(void)
+vm_resume_devices(void)
 {
 	const struct vm_snapshot_dev_info *info;
 	size_t i;
@@ -1090,7 +1089,7 @@ vm_snapshot_dev_write_data(int data_fd, xo_handle_t *xop, const char *array_key,
 }
 
 static int
-vm_snapshot_user_dev(const struct vm_snapshot_dev_info *info,
+vm_snapshot_device(const struct vm_snapshot_dev_info *info,
 		     int data_fd, xo_handle_t *xop,
 		     struct vm_snapshot_meta *meta, off_t *offset)
 {
@@ -1112,7 +1111,7 @@ vm_snapshot_user_dev(const struct vm_snapshot_dev_info *info,
 }
 
 static int
-vm_snapshot_user_devs(int data_fd, xo_handle_t *xop)
+vm_snapshot_devices(int data_fd, xo_handle_t *xop)
 {
 	int ret;
 	off_t offset;
@@ -1152,7 +1151,7 @@ vm_snapshot_user_devs(int data_fd, xo_handle_t *xop)
 		meta->buffer.buf = meta->buffer.buf_start;
 		meta->buffer.buf_rem = meta->buffer.buf_size;
 
-		ret = vm_snapshot_user_dev(&snapshot_devs[i], data_fd, xop,
+		ret = vm_snapshot_device(&snapshot_devs[i], data_fd, xop,
 					   meta, &offset);
 		if (ret != 0)
 			goto snapshot_err;
@@ -1294,7 +1293,7 @@ vm_checkpoint(struct vmctx *ctx, int fddir, const char *checkpoint_file,
 
 	vm_vcpu_pause(ctx);
 
-	ret = vm_pause_user_devs();
+	ret = vm_pause_devices();
 	if (ret != 0) {
 		fprintf(stderr, "Could not pause devices\r\n");
 		error = ret;
@@ -1322,7 +1321,7 @@ vm_checkpoint(struct vmctx *ctx, int fddir, const char *checkpoint_file,
 		goto done;
 	}
 
-	ret = vm_snapshot_user_devs(kdata_fd, xop);
+	ret = vm_snapshot_devices(kdata_fd, xop);
 	if (ret != 0) {
 		fprintf(stderr, "Failed to snapshot device state.\n");
 		error = -1;
@@ -1337,7 +1336,7 @@ vm_checkpoint(struct vmctx *ctx, int fddir, const char *checkpoint_file,
 	}
 
 done:
-	ret = vm_resume_user_devs();
+	ret = vm_resume_devices();
 	if (ret != 0)
 		fprintf(stderr, "Could not resume devices\r\n");
 	vm_vcpu_resume(ctx);
diff --git a/usr.sbin/bhyve/snapshot.h b/usr.sbin/bhyve/snapshot.h
index c3d0a7c8371a..95201deb1e5a 100644
--- a/usr.sbin/bhyve/snapshot.h
+++ b/usr.sbin/bhyve/snapshot.h
@@ -95,9 +95,9 @@ void checkpoint_cpu_suspend(int vcpu);
 int restore_vm_mem(struct vmctx *ctx, struct restore_state *rstate);
 int vm_restore_kern_structs(struct vmctx *ctx, struct restore_state *rstate);
 
-int vm_restore_user_devs(struct restore_state *rstate);
-int vm_pause_user_devs(void);
-int vm_resume_user_devs(void);
+int vm_restore_devices(struct restore_state *rstate);
+int vm_pause_devices(void);
+int vm_resume_devices(void);
 
 int get_checkpoint_msg(int conn_fd, struct vmctx *ctx);
 void *checkpoint_thread(void *param);