xref: /freebsd/share/man/man4/hv_vss.4 (revision 1cc60ae8d8871cf269e108b2f587def3e37551cf)
1168fce73SSepherosa Ziehau.\" Copyright (c) 2016 Microsoft Corp.
2168fce73SSepherosa Ziehau.\" All rights reserved.
3168fce73SSepherosa Ziehau.\"
4168fce73SSepherosa Ziehau.\" Redistribution and use in source and binary forms, with or without
5168fce73SSepherosa Ziehau.\" modification, are permitted provided that the following conditions
6168fce73SSepherosa Ziehau.\" are met:
7168fce73SSepherosa Ziehau.\" 1. Redistributions of source code must retain the above copyright
8168fce73SSepherosa Ziehau.\"    notice, this list of conditions and the following disclaimer.
9168fce73SSepherosa Ziehau.\" 2. Redistributions in binary form must reproduce the above copyright
10168fce73SSepherosa Ziehau.\"    notice, this list of conditions and the following disclaimer in the
11168fce73SSepherosa Ziehau.\"    documentation and/or other materials provided with the distribution.
12168fce73SSepherosa Ziehau.\"
13168fce73SSepherosa Ziehau.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
14168fce73SSepherosa Ziehau.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
15168fce73SSepherosa Ziehau.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
16168fce73SSepherosa Ziehau.\" ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
17168fce73SSepherosa Ziehau.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
18168fce73SSepherosa Ziehau.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
19168fce73SSepherosa Ziehau.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
20168fce73SSepherosa Ziehau.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
21168fce73SSepherosa Ziehau.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
22168fce73SSepherosa Ziehau.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
23168fce73SSepherosa Ziehau.\" SUCH DAMAGE.
24168fce73SSepherosa Ziehau.\"
25168fce73SSepherosa Ziehau.\" $FreeBSD$
26168fce73SSepherosa Ziehau.Dd October 12, 2016
27168fce73SSepherosa Ziehau.Dt HV_VSS 4
28168fce73SSepherosa Ziehau.Os
29168fce73SSepherosa Ziehau.Sh NAME
30168fce73SSepherosa Ziehau.Nm hv_vss
31168fce73SSepherosa Ziehau.Nd Hyper-V Volume Shadow Copy Service API
32168fce73SSepherosa Ziehau.Sh SYNOPSIS
33168fce73SSepherosa Ziehau.In dev/hyperv/hv_snapshot.h
34168fce73SSepherosa Ziehau.Bd -literal
35168fce73SSepherosa Ziehau#define VSS_SUCCESS		0x00000000
36168fce73SSepherosa Ziehau#define VSS_FAIL		0x00000001
37168fce73SSepherosa Ziehau
38168fce73SSepherosa Ziehauenum hv_vss_op_t {
39168fce73SSepherosa Ziehau	HV_VSS_NONE = 0,
40168fce73SSepherosa Ziehau	HV_VSS_CHECK,
41168fce73SSepherosa Ziehau	HV_VSS_FREEZE,
42168fce73SSepherosa Ziehau	HV_VSS_THAW,
43168fce73SSepherosa Ziehau	HV_VSS_COUNT
44168fce73SSepherosa Ziehau};
45168fce73SSepherosa Ziehau
46168fce73SSepherosa Ziehaustruct hv_vss_opt_msg {
47168fce73SSepherosa Ziehau	uint32_t	opt;		/* operation */
48168fce73SSepherosa Ziehau	uint32_t	status;		/* 0 for success, 1 for error */
49168fce73SSepherosa Ziehau	uint64_t	msgid;		/* an ID used to identify the transaction */
50168fce73SSepherosa Ziehau	uint8_t		reserved[48];	/* reserved values are all zeroes */
51168fce73SSepherosa Ziehau};
52168fce73SSepherosa Ziehau.Ed
53168fce73SSepherosa Ziehau.Sh DESCRIPTION
54168fce73SSepherosa ZiehauThe freeze or thaw functionality of application is important to guarantee
55*1cc60ae8SBenedict Reuschlingthe application consistent backup.
56*1cc60ae8SBenedict ReuschlingOn windows platform, VSS is defined to do live backup.
57*1cc60ae8SBenedict ReuschlingBut for VM guest running on Hyper-V, the corresponding VSS is
58*1cc60ae8SBenedict Reuschlingnot defined yet.
59*1cc60ae8SBenedict ReuschlingFor example, a running database server instance, it knows when the
60*1cc60ae8SBenedict Reuschlingapplications' freeze/thaw should start or finish.
61*1cc60ae8SBenedict ReuschlingBut it is not aware of the freeze/thaw notification from Hyper-V host.
62*1cc60ae8SBenedict ReuschlingThe
63168fce73SSepherosa Ziehau.Nm
64168fce73SSepherosa Ziehauis designed to notify application freeze/thaw request.
65168fce73SSepherosa ZiehauThus, it plays a role of broker to forward the freeze/thaw command from Hyper-V host
66168fce73SSepherosa Ziehauto userland application if it registered VSS service on
67168fce73SSepherosa Ziehau.Fx
68168fce73SSepherosa ZiehauVM, and sends the result back to Hyper-V host.
69168fce73SSepherosa Ziehau.Pp
70168fce73SSepherosa ZiehauGenerally,
71168fce73SSepherosa Ziehau.Xr hv_vss_daemon 8
726e069af4SEd Mastetakes the responsibility to freeze/thaw UFS file system,
73*1cc60ae8SBenedict Reuschlingand it is automatically launched after system boots.
74*1cc60ae8SBenedict ReuschlingWhen Hyper-V host wants to take a snapshot of the
75168fce73SSepherosa Ziehau.Fx
76168fce73SSepherosa ZiehauVM, it will first send VSS capability check to
77168fce73SSepherosa Ziehau.Fx
78*1cc60ae8SBenedict ReuschlingVM.
79*1cc60ae8SBenedict ReuschlingThe
80168fce73SSepherosa Ziehau.Nm
81168fce73SSepherosa Ziehaureceived the request and forward the request to userland application if it is
82*1cc60ae8SBenedict Reuschlingregistered.
83*1cc60ae8SBenedict ReuschlingOnly after
84168fce73SSepherosa Ziehau.Nm
85168fce73SSepherosa Ziehaureceived the VSS_SUCCESS response from application, the
86168fce73SSepherosa Ziehau.Xr hv_vss_daemon 8
87*1cc60ae8SBenedict Reuschlingwill be informed to check whether file system freeze/thaw is supported.
88*1cc60ae8SBenedict ReuschlingAny error occurs during this period,
89168fce73SSepherosa Ziehau.Nm
90*1cc60ae8SBenedict Reuschlingwill inform Hyper-V host that VSS is not supported.
91*1cc60ae8SBenedict ReuschlingIn addition, there is a default timeout limit before sending response to Hyper-V host.
92168fce73SSepherosa ZiehauIf the total response time from application and
93168fce73SSepherosa Ziehau.Xr hv_vss_daemon 8
94168fce73SSepherosa Ziehauexceeds this value, timeout
95168fce73SSepherosa Ziehauwill occurs and VSS unsupported is responsed to Hyper-V host.
96168fce73SSepherosa Ziehau.Pp
97168fce73SSepherosa ZiehauAfter Hyper-V host confirmed the
98168fce73SSepherosa Ziehau.Fx
99168fce73SSepherosa ZiehauVM supports VSS, it will send freeze request to VM, and
100168fce73SSepherosa Ziehau.Nm
101*1cc60ae8SBenedict Reuschlingwill first forward it to application.
102*1cc60ae8SBenedict ReuschlingAfter application finished freezing, it should inform
103168fce73SSepherosa Ziehau.Nm
104168fce73SSepherosa Ziehauand file system level freezing will be triggered by
105*1cc60ae8SBenedict Reuschling.Xr hv_vss_daemon 8 .
106*1cc60ae8SBenedict ReuschlingAfter all freezing on both application and
107168fce73SSepherosa Ziehau.Xr hv_vss_daemon 8
108168fce73SSepherosa Ziehauwere finished, the
109168fce73SSepherosa Ziehau.Nm
110*1cc60ae8SBenedict Reuschlingwill inform Hyper-V host that freezing is done.
111*1cc60ae8SBenedict ReuschlingOf course, there is a timeout limit as same as VSS capability is set to make sure freezing on
112168fce73SSepherosa Ziehau.Fx
113*1cc60ae8SBenedict ReuschlingVM is not hang.
114*1cc60ae8SBenedict ReuschlingIf there is any error occurs or timeout happened, the freezing is failed on Hyper-V side.
115168fce73SSepherosa Ziehau.Pp
116168fce73SSepherosa ZiehauHyper-V host will send thaw request after taking the snapshot, typically, this period is
117168fce73SSepherosa Ziehauvery short in order not to block the running application.
118168fce73SSepherosa Ziehau.Nm
119168fce73SSepherosa Ziehaufirstly thaw the file system by notifying
120168fce73SSepherosa Ziehau.Xr hv_vss_daemon 8 ,
121168fce73SSepherosa Ziehauthen notifies user registered
122*1cc60ae8SBenedict Reuschlingapplication.
123*1cc60ae8SBenedict ReuschlingThere is also a timeout check before sending response to Hyper-V host.
124168fce73SSepherosa Ziehau.Pp
125168fce73SSepherosa ZiehauAll the default timeout limit used in VSS capability check, freeze or thaw is the same.
126168fce73SSepherosa ZiehauIt is 15 seconds currently.
127168fce73SSepherosa Ziehau.Sh NOTES
128168fce73SSepherosa Ziehau.Nm
129*1cc60ae8SBenedict Reuschlingonly support UFS currently.
130*1cc60ae8SBenedict ReuschlingIf any of file system partition is non UFS, the VSS capability check will fail.
131*1cc60ae8SBenedict ReuschlingIf application does not register VSS,
132168fce73SSepherosa Ziehau.Nm
133*1cc60ae8SBenedict Reuschlingonly support backup for file system level consistent.
134*1cc60ae8SBenedict ReuschlingThe device should be closed before it was opened again.
135*1cc60ae8SBenedict ReuschlingIf you want to simultaneously open "/dev/hv_appvss_dev" two or more times,
136168fce73SSepherosa Ziehauan error (-1) will be returned, and errno was set.
137168fce73SSepherosa Ziehau.Pp
138168fce73SSepherosa ZiehauIf
139168fce73SSepherosa Ziehau.Xr hv_vss_daemon 8
140168fce73SSepherosa Ziehauwas killed after system boots, the VSS functionality will not work.
141168fce73SSepherosa Ziehau.Sh EXAMPLES
142168fce73SSepherosa ZiehauThe following is a complete example which does nothing except for waiting 2 seconds when
143168fce73SSepherosa Ziehaureceiving those notifications from
144168fce73SSepherosa Ziehau.Nm
145168fce73SSepherosa Ziehau.Bd -literal
146168fce73SSepherosa Ziehau#include <string.h>
147168fce73SSepherosa Ziehau#include <stdio.h>
148168fce73SSepherosa Ziehau#include <sys/ioctl.h>
149168fce73SSepherosa Ziehau#include <sys/param.h>
150168fce73SSepherosa Ziehau#include <sys/ucred.h>
151168fce73SSepherosa Ziehau#include <sys/mount.h>
152168fce73SSepherosa Ziehau#include <sys/types.h>
153168fce73SSepherosa Ziehau#include <unistd.h>
154168fce73SSepherosa Ziehau#include <stdlib.h>
155168fce73SSepherosa Ziehau#include <poll.h>
156168fce73SSepherosa Ziehau#include <stdint.h>
157168fce73SSepherosa Ziehau#include <syslog.h>
158168fce73SSepherosa Ziehau#include <errno.h>
159168fce73SSepherosa Ziehau#include <err.h>
160168fce73SSepherosa Ziehau#include <fcntl.h>
161168fce73SSepherosa Ziehau#include <ufs/ffs/fs.h>
162168fce73SSepherosa Ziehau#include <paths.h>
163168fce73SSepherosa Ziehau#include <sys/ioccom.h>
164168fce73SSepherosa Ziehau#include <dev/hyperv/hv_snapshot.h>
165168fce73SSepherosa Ziehau
166168fce73SSepherosa Ziehau#define UNDEF_FREEZE_THAW	(0)
167168fce73SSepherosa Ziehau#define FREEZE			(1)
168168fce73SSepherosa Ziehau#define THAW			(2)
169168fce73SSepherosa Ziehau#define CHECK			(3)
170168fce73SSepherosa Ziehau
171168fce73SSepherosa Ziehau#define	VSS_LOG(priority, format, args...) do	{				\\
172168fce73SSepherosa Ziehau		if (is_debugging == 1) {					\\
173168fce73SSepherosa Ziehau			if (is_daemon == 1)					\\
174168fce73SSepherosa Ziehau				syslog(priority, format, ## args);		\\
175168fce73SSepherosa Ziehau			else							\\
176168fce73SSepherosa Ziehau				printf(format, ## args);			\\
177168fce73SSepherosa Ziehau		} else {							\\
178168fce73SSepherosa Ziehau			if (priority < LOG_DEBUG) {				\\
179168fce73SSepherosa Ziehau				if (is_daemon == 1)				\\
180168fce73SSepherosa Ziehau					syslog(priority, format, ## args);	\\
181168fce73SSepherosa Ziehau				else						\\
182168fce73SSepherosa Ziehau					printf(format, ## args);		\\
183168fce73SSepherosa Ziehau			}							\\
184168fce73SSepherosa Ziehau		}								\\
185168fce73SSepherosa Ziehau	} while(0)
186168fce73SSepherosa Ziehau
187168fce73SSepherosa Ziehau#define CHECK_TIMEOUT		1
188168fce73SSepherosa Ziehau#define CHECK_FAIL		2
189168fce73SSepherosa Ziehau#define FREEZE_TIMEOUT		1
190168fce73SSepherosa Ziehau#define FREEZE_FAIL		2
191168fce73SSepherosa Ziehau#define THAW_TIMEOUT		1
192168fce73SSepherosa Ziehau#define THAW_FAIL		2
193168fce73SSepherosa Ziehau
194168fce73SSepherosa Ziehaustatic int is_daemon        = 1;
195168fce73SSepherosa Ziehaustatic int is_debugging     = 0;
196168fce73SSepherosa Ziehaustatic int simu_opt_waiting = 2; // seconds
197168fce73SSepherosa Ziehau
198168fce73SSepherosa Ziehau#define GENERIC_OPT(TIMEOUT, FAIL)						\\
199168fce73SSepherosa Ziehau	do {									\\
200168fce73SSepherosa Ziehau		sleep(simu_opt_waiting);					\\
201168fce73SSepherosa Ziehau		if (opt == CHECK_TIMEOUT) {					\\
202168fce73SSepherosa Ziehau			sleep(simu_opt_waiting * 10);				\\
203168fce73SSepherosa Ziehau			VSS_LOG(LOG_INFO, "%s timeout simulation\\n",		\\
204168fce73SSepherosa Ziehau			    __func__);						\\
205168fce73SSepherosa Ziehau			return (0);						\\
206168fce73SSepherosa Ziehau		} else if (opt == CHECK_FAIL) {					\\
207168fce73SSepherosa Ziehau			VSS_LOG(LOG_INFO, "%s failure simulation\\n",		\\
208168fce73SSepherosa Ziehau			    __func__);						\\
209168fce73SSepherosa Ziehau			return (CHECK_FAIL);					\\
210168fce73SSepherosa Ziehau		} else {							\\
211168fce73SSepherosa Ziehau			VSS_LOG(LOG_INFO, "%s success simulation\\n",		\\
212168fce73SSepherosa Ziehau			    __func__);						\\
213168fce73SSepherosa Ziehau			return (0);						\\
214168fce73SSepherosa Ziehau		}								\\
215168fce73SSepherosa Ziehau	} while (0)
216168fce73SSepherosa Ziehau
217168fce73SSepherosa Ziehaustatic int
218168fce73SSepherosa Ziehaucheck(int opt)
219168fce73SSepherosa Ziehau{
220168fce73SSepherosa Ziehau	GENERIC_OPT(CHECK_TIMEOUT, CHECK_FAIL);
221168fce73SSepherosa Ziehau}
222168fce73SSepherosa Ziehau
223168fce73SSepherosa Ziehaustatic int
224168fce73SSepherosa Ziehaufreeze(int opt)
225168fce73SSepherosa Ziehau{
226168fce73SSepherosa Ziehau	GENERIC_OPT(FREEZE_TIMEOUT, FREEZE_FAIL);
227168fce73SSepherosa Ziehau}
228168fce73SSepherosa Ziehau
229168fce73SSepherosa Ziehaustatic int
230168fce73SSepherosa Ziehauthaw(int opt)
231168fce73SSepherosa Ziehau{
232168fce73SSepherosa Ziehau	GENERIC_OPT(THAW_TIMEOUT, THAW_FAIL);
233168fce73SSepherosa Ziehau}
234168fce73SSepherosa Ziehau
235168fce73SSepherosa Ziehaustatic void usage(const char* cmd) {
236168fce73SSepherosa Ziehau	fprintf(stderr,
237168fce73SSepherosa Ziehau	    "%s -f <0|1|2>: simulate app freeze."
238168fce73SSepherosa Ziehau	    " 0: successful, 1: freeze timeout, 2: freeze failed\\n"
239168fce73SSepherosa Ziehau	    " -c <0|1|2>: simulate vss feature check"
240168fce73SSepherosa Ziehau	    " -t <0|1|2>: simulate app thaw."
241168fce73SSepherosa Ziehau	    " 0: successful, 1: freeze timeout, 2: freeze failed\\n"
242168fce73SSepherosa Ziehau	    " -d : enable debug mode\\n"
243168fce73SSepherosa Ziehau	    " -n : run this tool under non-daemon mode\\n", cmd);
244168fce73SSepherosa Ziehau}
245168fce73SSepherosa Ziehau
246168fce73SSepherosa Ziehauint
247168fce73SSepherosa Ziehaumain(int argc, char* argv[]) {
248168fce73SSepherosa Ziehau	int ch, freezesimuop = 0, thawsimuop = 0, checksimuop = 0, fd, r, error;
249168fce73SSepherosa Ziehau	uint32_t op;
250168fce73SSepherosa Ziehau	struct pollfd app_vss_fd[1];
251168fce73SSepherosa Ziehau	struct hv_vss_opt_msg  userdata;
252168fce73SSepherosa Ziehau
253168fce73SSepherosa Ziehau	while ((ch = getopt(argc, argv, "f:c:t:dnh")) != -1) {
254168fce73SSepherosa Ziehau		switch (ch) {
255168fce73SSepherosa Ziehau		case 'f':
256168fce73SSepherosa Ziehau			/* Run as regular process for debugging purpose. */
257168fce73SSepherosa Ziehau			freezesimuop = (int)strtol(optarg, NULL, 10);
258168fce73SSepherosa Ziehau			break;
259168fce73SSepherosa Ziehau		case 't':
260168fce73SSepherosa Ziehau			thawsimuop = (int)strtol(optarg, NULL, 10);
261168fce73SSepherosa Ziehau			break;
262168fce73SSepherosa Ziehau		case 'c':
263168fce73SSepherosa Ziehau			checksimuop = (int)strtol(optarg, NULL, 10);
264168fce73SSepherosa Ziehau			break;
265168fce73SSepherosa Ziehau		case 'd':
266168fce73SSepherosa Ziehau			is_debugging = 1;
267168fce73SSepherosa Ziehau			break;
268168fce73SSepherosa Ziehau		case 'n':
269168fce73SSepherosa Ziehau			is_daemon = 0;
270168fce73SSepherosa Ziehau			break;
271168fce73SSepherosa Ziehau		case 'h':
272168fce73SSepherosa Ziehau		default:
273168fce73SSepherosa Ziehau			usage(argv[0]);
274168fce73SSepherosa Ziehau			exit(0);
275168fce73SSepherosa Ziehau		}
276168fce73SSepherosa Ziehau	}
277168fce73SSepherosa Ziehau
278168fce73SSepherosa Ziehau	openlog("APPVSS", 0, LOG_USER);
279168fce73SSepherosa Ziehau	/* Become daemon first. */
280168fce73SSepherosa Ziehau	if (is_daemon == 1)
281168fce73SSepherosa Ziehau		daemon(1, 0);
282168fce73SSepherosa Ziehau	else
283168fce73SSepherosa Ziehau		VSS_LOG(LOG_DEBUG, "Run as regular process.\\n");
284168fce73SSepherosa Ziehau
285168fce73SSepherosa Ziehau	VSS_LOG(LOG_INFO, "HV_VSS starting; pid is: %d\\n", getpid());
286168fce73SSepherosa Ziehau
287168fce73SSepherosa Ziehau	fd = open(VSS_DEV(APP_VSS_DEV_NAME), O_RDWR);
288168fce73SSepherosa Ziehau	if (fd < 0) {
289168fce73SSepherosa Ziehau		VSS_LOG(LOG_ERR, "Fail to open %s, error: %d %s\\n",
290168fce73SSepherosa Ziehau		    VSS_DEV(APP_VSS_DEV_NAME), errno, strerror(errno));
291168fce73SSepherosa Ziehau		exit(EXIT_FAILURE);
292168fce73SSepherosa Ziehau	}
293168fce73SSepherosa Ziehau	app_vss_fd[0].fd     = fd;
294168fce73SSepherosa Ziehau	app_vss_fd[0].events = POLLIN | POLLRDNORM;
295168fce73SSepherosa Ziehau
296168fce73SSepherosa Ziehau	while (1) {
297168fce73SSepherosa Ziehau		r = poll(app_vss_fd, 1, INFTIM);
298168fce73SSepherosa Ziehau
299168fce73SSepherosa Ziehau		VSS_LOG(LOG_DEBUG, "poll returned r = %d, revent = 0x%x\\n",
300168fce73SSepherosa Ziehau		    r, app_vss_fd[0].revents);
301168fce73SSepherosa Ziehau
302168fce73SSepherosa Ziehau		if (r == 0 || (r < 0 && errno == EAGAIN) ||
303168fce73SSepherosa Ziehau		    (r < 0 && errno == EINTR)) {
304168fce73SSepherosa Ziehau			/* Nothing to read */
305168fce73SSepherosa Ziehau			continue;
306168fce73SSepherosa Ziehau		}
307168fce73SSepherosa Ziehau
308168fce73SSepherosa Ziehau		if (r < 0) {
309168fce73SSepherosa Ziehau			/*
310168fce73SSepherosa Ziehau			 * For poll return failure other than EAGAIN,
311168fce73SSepherosa Ziehau			 * we want to exit.
312168fce73SSepherosa Ziehau			 */
313168fce73SSepherosa Ziehau			VSS_LOG(LOG_ERR, "Poll failed.\\n");
314168fce73SSepherosa Ziehau			perror("poll");
315168fce73SSepherosa Ziehau			exit(EIO);
316168fce73SSepherosa Ziehau		}
317168fce73SSepherosa Ziehau
318168fce73SSepherosa Ziehau		/* Read from character device */
319168fce73SSepherosa Ziehau		error = ioctl(fd, IOCHVVSSREAD, &userdata);
320168fce73SSepherosa Ziehau		if (error < 0) {
321168fce73SSepherosa Ziehau			VSS_LOG(LOG_ERR, "Read failed.\\n");
322168fce73SSepherosa Ziehau			perror("pread");
323168fce73SSepherosa Ziehau			exit(EIO);
324168fce73SSepherosa Ziehau		}
325168fce73SSepherosa Ziehau
326168fce73SSepherosa Ziehau		if (userdata.status != 0) {
327168fce73SSepherosa Ziehau			VSS_LOG(LOG_ERR, "data read error\\n");
328168fce73SSepherosa Ziehau			continue;
329168fce73SSepherosa Ziehau		}
330168fce73SSepherosa Ziehau
331168fce73SSepherosa Ziehau		op = userdata.opt;
332168fce73SSepherosa Ziehau
333168fce73SSepherosa Ziehau		switch (op) {
334168fce73SSepherosa Ziehau		case HV_VSS_CHECK:
335168fce73SSepherosa Ziehau			error = check(checksimuop);
336168fce73SSepherosa Ziehau			break;
337168fce73SSepherosa Ziehau		case HV_VSS_FREEZE:
338168fce73SSepherosa Ziehau			error = freeze(freezesimuop);
339168fce73SSepherosa Ziehau			break;
340168fce73SSepherosa Ziehau		case HV_VSS_THAW:
341168fce73SSepherosa Ziehau			error = thaw(thawsimuop);
342168fce73SSepherosa Ziehau			break;
343168fce73SSepherosa Ziehau		default:
344168fce73SSepherosa Ziehau			VSS_LOG(LOG_ERR, "Illegal operation: %d\\n", op);
345168fce73SSepherosa Ziehau			error = VSS_FAIL;
346168fce73SSepherosa Ziehau		}
347168fce73SSepherosa Ziehau		if (error)
348168fce73SSepherosa Ziehau			userdata.status = VSS_FAIL;
349168fce73SSepherosa Ziehau		else
350168fce73SSepherosa Ziehau			userdata.status = VSS_SUCCESS;
351168fce73SSepherosa Ziehau		error = ioctl(fd, IOCHVVSSWRITE, &userdata);
352168fce73SSepherosa Ziehau		if (error != 0) {
353168fce73SSepherosa Ziehau			VSS_LOG(LOG_ERR, "Fail to write to device\\n");
354168fce73SSepherosa Ziehau			exit(EXIT_FAILURE);
355168fce73SSepherosa Ziehau		} else {
356168fce73SSepherosa Ziehau			VSS_LOG(LOG_INFO, "Send response %d for %s to kernel\\n",
357168fce73SSepherosa Ziehau			    userdata.status, op == HV_VSS_FREEZE ? "Freeze" :
358168fce73SSepherosa Ziehau			    (op == HV_VSS_THAW ? "Thaw" : "Check"));
359168fce73SSepherosa Ziehau		}
360168fce73SSepherosa Ziehau	}
361168fce73SSepherosa Ziehau	return 0;
362168fce73SSepherosa Ziehau}
3632940eb19SChristian Brueffer.Ed
364168fce73SSepherosa Ziehau.Sh SEE ALSO
3652940eb19SChristian Brueffer.Xr hv_utils 4 ,
3662940eb19SChristian Brueffer.Xr hv_vss_daemon 8
367168fce73SSepherosa Ziehau.Sh HISTORY
368168fce73SSepherosa ZiehauThe daemon was introduced in October 2016 and developed by Microsoft Corp.
369168fce73SSepherosa Ziehau.Sh AUTHORS
370168fce73SSepherosa Ziehau.An -nosplit
371168fce73SSepherosa Ziehau.Fx
372168fce73SSepherosa Ziehausupport for
373168fce73SSepherosa Ziehau.Nm
374168fce73SSepherosa Ziehauwas first added by
375168fce73SSepherosa Ziehau.An Microsoft BSD Integration Services Team Aq Mt bsdic@microsoft.com .
376