* [PATCH] [PATCH RFC v2] Implements Backend Program conventions for vhost-user-scsi
@ 2022-04-03 7:21 Sakshi Kaushik
2022-04-03 19:46 ` Stefan Hajnoczi
0 siblings, 1 reply; 5+ messages in thread
From: Sakshi Kaushik @ 2022-04-03 7:21 UTC (permalink / raw)
To: qemu-devel; +Cc: raphel.norwitz, Sakshi Kaushik, stefanha, mst
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
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH] [PATCH RFC v2] Implements Backend Program conventions for vhost-user-scsi
2022-04-03 7:21 [PATCH] [PATCH RFC v2] Implements Backend Program conventions for vhost-user-scsi Sakshi Kaushik
@ 2022-04-03 19:46 ` Stefan Hajnoczi
[not found] ` <CAFt73e_Rku3pgQ+YAj-zAcrq36JJd1A1pBA-AX8JMrqRY0f5TA@mail.gmail.com>
0 siblings, 1 reply; 5+ messages in thread
From: Stefan Hajnoczi @ 2022-04-03 19:46 UTC (permalink / raw)
To: Sakshi Kaushik; +Cc: raphel.norwitz, qemu-devel, stefanha, mst
[-- Attachment #1: Type: text/plain, Size: 3822 bytes --]
On Sun, Apr 03, 2022 at 02:21:48AM -0500, Sakshi Kaushik wrote:
Hi Sakshi,
Thanks for the patch. I left comments below on things that are
incomplete. Please compile and run it with the new command-line options
you've added to test if the code works.
> 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;
Why are these variables declared static?
> VusDev *vdev_scsi = NULL;
> char *unix_fn = NULL;
> char *iscsi_uri = NULL;
> @@ -362,12 +364,18 @@ int main(int argc, char **argv)
> switch (opt) {
The getopt(3) call needs to be extended to parse --socket-path, --fd, and
--print-capabilities. getopt_long(3) or GOptionContext APIs could be
used to parse these long options.
> 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);
This statement sets opt_print_caps to true and leaks the string
allocated by g_strdup(). opt_print_caps is a gboolean, I think this
should just be:
opt_print_caps = true;
> + 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));
This looks like it was copy-pasted from another program that uses
GOptionContext but vhost-user-scsi.c:main() uses getopt(3) (a different
API) so it won't work here.
> + exit(EXIT_FAILURE);
> + } else {
> + lsock = opt_fdnum;
> + }
> +
> + if (opt_print_caps) {
> + if (opt_print_caps["type"] != "scsi") {
> + goto err;
> + }
This option does not need to validate input (there is no input). Instead
it needs to output JSON according to the vhost-user.rst backend
convention specification. Something like:
printf("{\n");
printf(" \"type\": \"scsi\"\n");
printf("}\n");
goto out;
> }
>
> 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
>
>
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] [PATCH RFC v2] Implements Backend Program conventions for vhost-user-scsi
[not found] ` <CAFt73e_Rku3pgQ+YAj-zAcrq36JJd1A1pBA-AX8JMrqRY0f5TA@mail.gmail.com>
@ 2022-04-04 8:29 ` Stefan Hajnoczi
[not found] ` <CAFt73e-2pf1XDp66PVCPq4kUiegChJGhaiEyHAvyWUf77jbNEw@mail.gmail.com>
0 siblings, 1 reply; 5+ messages in thread
From: Stefan Hajnoczi @ 2022-04-04 8:29 UTC (permalink / raw)
To: Sakshi Kaushik; +Cc: Michael S. Tsirkin, qemu-devel, Raphael Norwitz
On Mon, 4 Apr 2022 at 00:16, Sakshi Kaushik <sakshikaushik717@gmail.com> wrote:
> I have made the suggested changes and submitted v3.
> But I am not sure how to check this code by running it? When I try to run the .c code I get the error message: 'qemu/osdep.h' no such file or directory.
>
> I have followed the building step without error. Not sure if I'm doing it correctly.
The executable will be in
build/contrib/vhost-user-scsi/vhost-user-scsi after you run 'make'. If
you ran make from the root of the QEMU source tree you can run the
program like this:
$ build/contrib/vhost-user-scsi/vhost-user-scsi
This will let you check that the new command-line options work and
that the help output is updated.
The simplest way to check that vhost-user-scsi is listening on the
given UNIX domain socket path (--socket-path) or file descriptor
(--fd) is using:
$ netstat --unix --listening --program
This shows all processes that are listening on a UNIX domain socket.
You can search for the PID of the vhost-user-scsi process to see if
it's listed.
Stefan
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] [PATCH RFC v2] Implements Backend Program conventions for vhost-user-scsi
[not found] ` <CAFt73e-2pf1XDp66PVCPq4kUiegChJGhaiEyHAvyWUf77jbNEw@mail.gmail.com>
@ 2022-04-04 15:44 ` Stefan Hajnoczi
0 siblings, 0 replies; 5+ messages in thread
From: Stefan Hajnoczi @ 2022-04-04 15:44 UTC (permalink / raw)
To: Sakshi Kaushik; +Cc: Raphael Norwitz, qemu-devel, Michael S. Tsirkin
On Mon, 4 Apr 2022 at 15:51, Sakshi Kaushik <sakshikaushik717@gmail.com> wrote:
> I am not able to find vhost-user-scsi inside build/contrib/vhost-user-scsi despite running the 'make' command.
It is probably not being built because the dependencies are not
installed on your machine. Here are the contents of the
contrib/vhost-user-scsi/meson.build file:
if libiscsi.found()
executable('vhost-user-scsi', files('vhost-user-scsi.c'),
dependencies: [qemuutil, libiscsi, vhost_user],
build_by_default: targetos == 'linux',
install: false)
endif
The build machine must be a Linux machine and it must have the
libiscsi-dev (Debian/Ubuntu), libiscsi-devel (Fedora/CentOS/RHEL), or
similarly-named package installed. You can run QEMU's ./configure
script and look at the output to see if it detected libiscsi.
Stefan
^ permalink raw reply [flat|nested] 5+ messages in thread
* [PATCH] [PATCH RFC v2] Implements Backend Program conventions for vhost-user-scsi
@ 2022-04-01 4:48 Sakshi Kaushik
0 siblings, 0 replies; 5+ messages in thread
From: Sakshi Kaushik @ 2022-04-01 4:48 UTC (permalink / raw)
To: qemu-devel; +Cc: stefanha, raphel.norwitz, Sakshi Kaushik, mst
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
^ permalink raw reply related [flat|nested] 5+ messages in thread
end of thread, other threads:[~2022-04-04 15:52 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-04-03 7:21 [PATCH] [PATCH RFC v2] Implements Backend Program conventions for vhost-user-scsi Sakshi Kaushik
2022-04-03 19:46 ` Stefan Hajnoczi
[not found] ` <CAFt73e_Rku3pgQ+YAj-zAcrq36JJd1A1pBA-AX8JMrqRY0f5TA@mail.gmail.com>
2022-04-04 8:29 ` Stefan Hajnoczi
[not found] ` <CAFt73e-2pf1XDp66PVCPq4kUiegChJGhaiEyHAvyWUf77jbNEw@mail.gmail.com>
2022-04-04 15:44 ` Stefan Hajnoczi
-- strict thread matches above, loose matches on Subject: below --
2022-04-01 4:48 Sakshi Kaushik
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.