summaryrefslogtreecommitdiffstats
path: root/dev-tools
diff options
context:
space:
mode:
authorjandob2016-01-21 15:33:05 +0100
committerjandob2016-01-21 15:33:05 +0100
commita96b6abcb91e3a96f9ef7a1bdbb95dadfb28f457 (patch)
treec87343b988937956a6462bc574cd89e3efbe619d /dev-tools
parentadd debugging options to ipxe (diff)
parentRemove qemu to make space for xmount. (diff)
downloadsystemd-init-a96b6abcb91e3a96f9ef7a1bdbb95dadfb28f457.tar.gz
systemd-init-a96b6abcb91e3a96f9ef7a1bdbb95dadfb28f457.tar.xz
systemd-init-a96b6abcb91e3a96f9ef7a1bdbb95dadfb28f457.zip
merge
Diffstat (limited to 'dev-tools')
-rw-r--r--dev-tools/qemuDebuggingPatch/qemu-nbd.c116
1 files changed, 66 insertions, 50 deletions
diff --git a/dev-tools/qemuDebuggingPatch/qemu-nbd.c b/dev-tools/qemuDebuggingPatch/qemu-nbd.c
index 3af28a07..ce0043d4 100644
--- a/dev-tools/qemuDebuggingPatch/qemu-nbd.c
+++ b/dev-tools/qemuDebuggingPatch/qemu-nbd.c
@@ -244,64 +244,80 @@ static void *nbd_client_thread(void *arg)
pthread_t show_parts_thread;
Error *local_error = NULL;
+ // changed
+ while(1) {
+ // --
+ sock = socket_connect(saddr, &local_error, NULL, NULL);
+ if (sock < 0) {
+ error_report_err(local_error);
+ goto out;
+ }
- sock = socket_connect(saddr, &local_error, NULL, NULL);
- if (sock < 0) {
- error_report_err(local_error);
- goto out;
- }
-
- ret = nbd_receive_negotiate(sock, NULL, &nbdflags,
- &size, &local_error);
- if (ret < 0) {
- if (local_error) {
- fprintf(stderr, "%s\n", error_get_pretty(local_error));
- error_free(local_error);
+ ret = nbd_receive_negotiate(sock, NULL, &nbdflags,
+ &size, &local_error);
+ if (ret < 0) {
+ if (local_error) {
+ fprintf(stderr, "%s\n", error_get_pretty(local_error));
+ error_free(local_error);
+ }
+ goto out_socket;
}
- goto out_socket;
- }
- fd = open(device, O_RDWR);
- if (fd < 0) {
- /* Linux-only, we can use %m in printf. */
- fprintf(stderr, "Failed to open %s: %m\n", device);
- goto out_socket;
- }
+ fd = open(device, O_RDWR);
+ if (fd < 0) {
+ /* Linux-only, we can use %m in printf. */
+ fprintf(stderr, "Failed to open %s: %m\n", device);
+ goto out_socket;
+ }
- ret = nbd_init(fd, sock, nbdflags, size);
- if (ret < 0) {
- fprintf(stderr, "------------------------\nJAU: nbd_client_thread -> trigger out_fd caused by nbd_init PID: %d\n-------------------\n", getpid());
- goto out_fd;
- }
+ ret = nbd_init(fd, sock, nbdflags, size);
+ if (ret < 0) {
+ fprintf(stderr, "------------------------\nJAU: nbd_client_thread -> trigger out_fd caused by nbd_init PID: %d\n-------------------\n", getpid());
+ goto out_fd;
+ }
- /* update partition table */
- pthread_create(&show_parts_thread, NULL, show_parts, device);
+ /* update partition table */
+ pthread_create(&show_parts_thread, NULL, show_parts, device);
- if (verbose) {
- fprintf(stderr, "NBD device %s is now connected to %s\n",
- device, srcpath);
- } else {
- /* Close stderr so that the qemu-nbd process exits. */
- dup2(STDOUT_FILENO, STDERR_FILENO);
- }
+ if (verbose) {
+ fprintf(stderr, "NBD device %s is now connected to %s\n",
+ device, srcpath);
+ } else {
+ /* Close stderr so that the qemu-nbd process exits. */
+ dup2(STDOUT_FILENO, STDERR_FILENO);
+ }
- // Changed
- pid_t pid;
- pid = fork();
- if (pid == 0) {
- fprintf(stderr, "------------------------\nJAU: nbd_client -> custom fork sleep started PID: %d\n-------------------\n", getpid());
- sleep(10);
- int a = chdir("/sysroot/");
- fprintf(stderr, "------------------------\nJAU: nbd_client -> custom fork sleep finished chdir returned %d PID: %d\n-------------------\n", a, getpid());
- exit(0);
- }
- // --
- ret = nbd_client(fd);
- if (ret) {
- fprintf(stderr, "------------------------\nJAU: nbd_client_thread -> trigger out_fd caused by nbd_client PID: %d\n-------------------\n", getpid());
- goto out_fd;
+ /* Changed
+ pid_t pid;
+ pid = fork();
+ if (pid == 0) {
+ fprintf(stderr, "------------------------\nJAU: nbd_client -> custom fork sleep started PID: %d\n-------------------\n", getpid());
+ sleep(10);
+ int a = chdir("/sysroot/");
+ fprintf(stderr, "------------------------\nJAU: nbd_client -> custom fork sleep finished chdir returned %d PID: %d\n-------------------\n", a, getpid());
+ exit(0);
+ }
+ */
+ ret = nbd_client(fd);
+ // changed
+ if (errno == ETIMEDOUT) {
+ fprintf(stderr, "------------------------\nJAU: nbd_client_thread -> trigger out_fd caused by nbd_client -> BUT Ignored and starting reconnect! PID: %d\n-------------------\n", getpid());
+ close(fd);
+ continue;
+ }
+ //
+ if (ret) {
+ goto out_fd;
+ // changed
+ } else {
+ close(fd);
+ break;
+ }
+ //
+ close(fd);
+ // changed
}
- close(fd);
+ //--
kill(getpid(), SIGTERM);
fprintf(stderr, "------------------------\nJAU: nbd_client_thread -> STOP PID: %d\n-------------------\n", getpid());
return (void *) EXIT_SUCCESS;