qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[PATCH] [PATCH RFC v2] Implements Backend Program conventions for vhost-


From: Sakshi Kaushik
Subject: [PATCH] [PATCH RFC v2] Implements Backend Program conventions for vhost-user-scsi
Date: Thu, 31 Mar 2022 23:48:15 -0500

Signed-off-by: Sakshi Kaushik <sakshikaushik717@gmail.com>
---
 contrib/vhost-user-scsi/vhost-user-scsi.c | 35 +++++++++++++++++++----
 1 file changed, 29 insertions(+), 6 deletions(-)

diff --git a/contrib/vhost-user-scsi/vhost-user-scsi.c 
b/contrib/vhost-user-scsi/vhost-user-scsi.c
index 4f6e3e2a24..9bdc088ce8 100644
--- a/contrib/vhost-user-scsi/vhost-user-scsi.c
+++ b/contrib/vhost-user-scsi/vhost-user-scsi.c
@@ -353,6 +353,8 @@ fail:
 
 int main(int argc, char **argv)
 {
+    static int opt_fdnum = -1;
+    static gboolean opt_print_caps;
     VusDev *vdev_scsi = NULL;
     char *unix_fn = NULL;
     char *iscsi_uri = NULL;
@@ -362,12 +364,18 @@ int main(int argc, char **argv)
         switch (opt) {
         case 'h':
             goto help;
-        case 'u':
+        case 's':
             unix_fn = g_strdup(optarg);
             break;
         case 'i':
             iscsi_uri = g_strdup(optarg);
             break;
+        case 'f':
+            opt_fdnum = g_strdup(optarg);
+            break;
+        case 'p':
+            opt_print_caps = g_strdup(optarg);
+            break;
         default:
             goto help;
         }
@@ -376,9 +384,22 @@ int main(int argc, char **argv)
         goto help;
     }
 
-    lsock = unix_sock_new(unix_fn);
-    if (lsock < 0) {
-        goto err;
+    if (unix_fn) {
+        lsock = unix_sock_new(unix_fn);
+        if (lsock < 0) {
+            exit(EXIT_FAILURE);
+        }
+    } else if (opt_fdnum < 0) {
+        g_print("%s\n", g_option_context_get_help(context, true, NULL));
+        exit(EXIT_FAILURE);
+    } else {
+        lsock = opt_fdnum;
+    }
+
+    if (opt_print_caps) {
+        if (opt_print_caps["type"] != "scsi") {
+            goto err;
+        }
     }
 
     csock = accept(lsock, NULL, NULL);
@@ -426,10 +447,12 @@ err:
     goto out;
 
 help:
-    fprintf(stderr, "Usage: %s [ -u unix_sock_path -i iscsi_uri ] | [ -h ]\n",
+    fprintf(stderr, "Usage: %s [ -s socket-path -i iscsi_uri -f fd -p 
print-capabilities ] | [ -h ]\n",
             argv[0]);
-    fprintf(stderr, "          -u path to unix socket\n");
+    fprintf(stderr, "          -s path to unix socket\n");
     fprintf(stderr, "          -i iscsi uri for lun 0\n");
+    fprintf(stderr, "          -f fd, file-descriptor\n");
+    fprintf(stderr, "          -p denotes print-capabilities\n");
     fprintf(stderr, "          -h print help and quit\n");
 
     goto err;
-- 
2.17.1




reply via email to

[Prev in Thread] Current Thread [Next in Thread]