]> git.proxmox.com Git - mirror_qemu.git/blobdiff - qemu-nbd.c
s390x/skeys: Fix instance and class size
[mirror_qemu.git] / qemu-nbd.c
index 706552e64ce6266f4267fd6194e31b2a5455dba2..ede4a54d4ed7f25fb2cedd1b6ac7f6a0b9379e3c 100644 (file)
@@ -156,8 +156,7 @@ static int find_partition(BlockBackend *blk, int partition,
     int ret;
 
     if ((ret = blk_read(blk, 0, data, 1)) < 0) {
-        errno = -ret;
-        error_report("error while reading: %s", strerror(errno));
+        error_report("error while reading: %s", strerror(-ret));
         exit(EXIT_FAILURE);
     }
 
@@ -178,8 +177,7 @@ static int find_partition(BlockBackend *blk, int partition,
             int j;
 
             if ((ret = blk_read(blk, mbr[i].start_sector_abs, data1, 1)) < 0) {
-                errno = -ret;
-                error_report("error while reading: %s", strerror(errno));
+                error_report("error while reading: %s", strerror(-ret));
                 exit(EXIT_FAILURE);
             }
 
@@ -259,7 +257,7 @@ static void *nbd_client_thread(void *arg)
     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);
+        error_report("Failed to open %s: %m", device);
         goto out_socket;
     }
 
@@ -335,13 +333,9 @@ static void nbd_accept(void *opaque)
         return;
     }
 
-    if (nbd_client_new(exp, fd, nbd_client_closed)) {
-        nb_fds++;
-        nbd_update_server_fd_handler(server_fd);
-    } else {
-        shutdown(fd, 2);
-        close(fd);
-    }
+    nb_fds++;
+    nbd_update_server_fd_handler(server_fd);
+    nbd_client_new(exp, fd, nbd_client_closed);
 }
 
 static void nbd_update_server_fd_handler(int fd)
@@ -497,8 +491,8 @@ int main(int argc, char **argv)
                                 BLOCKDEV_DETECT_ZEROES_OPTIONS_OFF,
                                 &local_err);
             if (local_err) {
-                error_report("Failed to parse detect_zeroes mode: %s",
-                             error_get_pretty(local_err));
+                error_reportf_err(local_err,
+                                  "Failed to parse detect_zeroes mode: ");
                 exit(EXIT_FAILURE);
             }
             if (detect_zeroes == BLOCKDEV_DETECT_ZEROES_OPTIONS_UNMAP &&
@@ -556,7 +550,7 @@ int main(int argc, char **argv)
         case 'k':
             sockpath = optarg;
             if (sockpath[0] != '/') {
-                error_report("socket path must be absolute\n");
+                error_report("socket path must be absolute");
                 exit(EXIT_FAILURE);
             }
             break;
@@ -573,7 +567,7 @@ int main(int argc, char **argv)
                 exit(EXIT_FAILURE);
             }
             if (shared < 1) {
-                error_report("Shared device number must be greater than 0\n");
+                error_report("Shared device number must be greater than 0");
                 exit(EXIT_FAILURE);
             }
             break;
@@ -601,9 +595,8 @@ int main(int argc, char **argv)
     }
 
     if ((argc - optind) != 1) {
-        error_report("Invalid number of argument.\n"
-                     "Try `%s --help' for more information.",
-                     argv[0]);
+        error_report("Invalid number of arguments");
+        error_printf("Try `%s --help' for more information.\n", argv[0]);
         exit(EXIT_FAILURE);
     }
 
@@ -705,8 +698,8 @@ int main(int argc, char **argv)
     srcpath = argv[optind];
     blk = blk_new_open("hda", srcpath, NULL, options, flags, &local_err);
     if (!blk) {
-        error_report("Failed to blk_new_open '%s': %s", argv[optind],
-                     error_get_pretty(local_err));
+        error_reportf_err(local_err, "Failed to blk_new_open '%s': ",
+                          argv[optind]);
         exit(EXIT_FAILURE);
     }
     bs = blk_bs(blk);
@@ -721,9 +714,7 @@ int main(int argc, char **argv)
                                                    &local_err);
     }
     if (ret < 0) {
-        errno = -ret;
-        error_report("Failed to load snapshot: %s: %s",
-                     error_get_pretty(local_err), strerror(errno));
+        error_reportf_err(local_err, "Failed to load snapshot: ");
         exit(EXIT_FAILURE);
     }
 
@@ -738,9 +729,8 @@ int main(int argc, char **argv)
     if (partition != -1) {
         ret = find_partition(blk, partition, &dev_offset, &fd_size);
         if (ret < 0) {
-            errno = -ret;
             error_report("Could not find partition %d: %s", partition,
-                         strerror(errno));
+                         strerror(-ret));
             exit(EXIT_FAILURE);
         }
     }