|
@@ -61,6 +61,7 @@
|
|
#define QEMU_NBD_OPT_IMAGE_OPTS 262
|
|
#define QEMU_NBD_OPT_IMAGE_OPTS 262
|
|
#define QEMU_NBD_OPT_FORK 263
|
|
#define QEMU_NBD_OPT_FORK 263
|
|
#define QEMU_NBD_OPT_TLSAUTHZ 264
|
|
#define QEMU_NBD_OPT_TLSAUTHZ 264
|
|
|
|
+#define QEMU_NBD_OPT_PID_FILE 265
|
|
|
|
|
|
#define MBR_SIZE 512
|
|
#define MBR_SIZE 512
|
|
|
|
|
|
@@ -113,6 +114,7 @@ static void usage(const char *name)
|
|
" specify tracing options\n"
|
|
" specify tracing options\n"
|
|
" --fork fork off the server process and exit the parent\n"
|
|
" --fork fork off the server process and exit the parent\n"
|
|
" once the server is running\n"
|
|
" once the server is running\n"
|
|
|
|
+" --pid-file=PATH store the server's process ID in the given file\n"
|
|
#if HAVE_NBD_DEVICE
|
|
#if HAVE_NBD_DEVICE
|
|
"\n"
|
|
"\n"
|
|
"Kernel NBD client support:\n"
|
|
"Kernel NBD client support:\n"
|
|
@@ -641,6 +643,7 @@ int main(int argc, char **argv)
|
|
{ "image-opts", no_argument, NULL, QEMU_NBD_OPT_IMAGE_OPTS },
|
|
{ "image-opts", no_argument, NULL, QEMU_NBD_OPT_IMAGE_OPTS },
|
|
{ "trace", required_argument, NULL, 'T' },
|
|
{ "trace", required_argument, NULL, 'T' },
|
|
{ "fork", no_argument, NULL, QEMU_NBD_OPT_FORK },
|
|
{ "fork", no_argument, NULL, QEMU_NBD_OPT_FORK },
|
|
|
|
+ { "pid-file", required_argument, NULL, QEMU_NBD_OPT_PID_FILE },
|
|
{ NULL, 0, NULL, 0 }
|
|
{ NULL, 0, NULL, 0 }
|
|
};
|
|
};
|
|
int ch;
|
|
int ch;
|
|
@@ -667,6 +670,7 @@ int main(int argc, char **argv)
|
|
bool list = false;
|
|
bool list = false;
|
|
int old_stderr = -1;
|
|
int old_stderr = -1;
|
|
unsigned socket_activation;
|
|
unsigned socket_activation;
|
|
|
|
+ const char *pid_file_name = NULL;
|
|
|
|
|
|
/* The client thread uses SIGTERM to interrupt the server. A signal
|
|
/* The client thread uses SIGTERM to interrupt the server. A signal
|
|
* handler ensures that "qemu-nbd -v -c" exits with a nice status code.
|
|
* handler ensures that "qemu-nbd -v -c" exits with a nice status code.
|
|
@@ -866,6 +870,9 @@ int main(int argc, char **argv)
|
|
case 'L':
|
|
case 'L':
|
|
list = true;
|
|
list = true;
|
|
break;
|
|
break;
|
|
|
|
+ case QEMU_NBD_OPT_PID_FILE:
|
|
|
|
+ pid_file_name = optarg;
|
|
|
|
+ break;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
@@ -1186,6 +1193,10 @@ int main(int argc, char **argv)
|
|
|
|
|
|
nbd_update_server_watch();
|
|
nbd_update_server_watch();
|
|
|
|
|
|
|
|
+ if (pid_file_name) {
|
|
|
|
+ qemu_write_pidfile(pid_file_name, &error_fatal);
|
|
|
|
+ }
|
|
|
|
+
|
|
/* now when the initialization is (almost) complete, chdir("/")
|
|
/* now when the initialization is (almost) complete, chdir("/")
|
|
* to free any busy filesystems */
|
|
* to free any busy filesystems */
|
|
if (chdir("/") < 0) {
|
|
if (chdir("/") < 0) {
|