1 /* SPDX-License-Identifier: MIT */
2 
3 /*
4  * Live Update interfaces for Xen Store Daemon.
5  * Copyright (C) 2022 Juergen Gross, SUSE LLC
6  */
7 
8 #ifndef NO_LIVE_UPDATE
9 struct live_update {
10 	/* For verification the correct connection is acting. */
11 	struct connection *conn;
12 
13 	/* Pointer to the command used to request LU */
14 	struct buffered_data *in;
15 
16 #ifdef __MINIOS__
17 	void *kernel;
18 	unsigned int kernel_size;
19 	unsigned int kernel_off;
20 
21 	void *dump_state;
22 	unsigned long dump_size;
23 #else
24 	char *filename;
25 #endif
26 
27 	char *cmdline;
28 
29 	/* Start parameters. */
30 	bool force;
31 	unsigned int timeout;
32 	time_t started_at;
33 };
34 
35 struct lu_dump_state {
36 	void *buf;
37 	unsigned int size;
38 #ifndef __MINIOS__
39 	int fd;
40 	char *filename;
41 #endif
42 };
43 
44 extern struct live_update *lu_status;
45 
46 struct connection *lu_get_connection(void);
47 bool lu_is_pending(void);
48 void lu_read_state(void);
49 
50 /* Write the "OK" response for the live-update command */
51 unsigned int lu_write_response(FILE *fp);
52 
53 int do_control_lu(const void *ctx, struct connection *conn, const char **vec,
54 		  int num);
55 
56 /* Live update private interfaces. */
57 void lu_get_dump_state(struct lu_dump_state *state);
58 void lu_close_dump_state(struct lu_dump_state *state);
59 FILE *lu_dump_open(const void *ctx);
60 void lu_dump_close(FILE *fp);
61 char *lu_exec(const void *ctx, int argc, char **argv);
62 const char *lu_arch(const void *ctx, struct connection *conn, const char **vec,
63 		    int num);
64 const char *lu_begin(struct connection *conn);
65 void lu_destroy_arch(void *data);
66 #else
lu_get_connection(void)67 static inline struct connection *lu_get_connection(void)
68 {
69 	return NULL;
70 }
71 
lu_write_response(FILE * fp)72 static inline unsigned int lu_write_response(FILE *fp)
73 {
74 	return 0;
75 }
76 
lu_is_pending(void)77 static inline bool lu_is_pending(void)
78 {
79 	return false;
80 }
81 #endif
82