Skip to contentSkip to conversation

vl.c: call bdrv_init_with_whitelist() before cmdline parsing

PATCH Applied Peter Lieven 3 participants 7 messages Mar 21, 2013 – Mar 26, 2013

lore
Share & tools
lore
#0 lore raw

PATCH 1/2 vl.c: call bdrv_init_with_whitelist() before cmdline parsing

commit 4d454574 "qemu-option: move standard option definitions out of qemu-config.c" broke support for commandline option groups that where registered during bdrv_init(). In particular support for -iscsi options was broken since that commit.

Fix by moving the bdrv_init_with_whitelist() before command line argument parsing.

---
 vl.c |    4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
vl.c +2 -2
index aeed7f4..315d43d 100644
@@ -2935,6 +2935,8 @@ int main(int argc, char **argv, char **envp)
 
     nb_numa_nodes = 0;
     nb_nics = 0;
+    
+    bdrv_init_with_whitelist();
 
     autostart= 1;
 
@@ -4194,8 +4196,6 @@ int main(int argc, char **argv, char **envp)
 
     cpu_exec_init_all();
 
-    bdrv_init_with_whitelist();
-
     blk_mig_init();
 
     /* open the virtual block devices */
Signature · 1 line
1.7.9.5
#1 lore raw

PATCH 2/2 vl.c: throw an error if iscsi is not supported

this patch adds a check for qemu_find_opts("iscsi") returning NULL instead of blindly passing the result to qemu_opts_parse().

---
 vl.c |    9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)
vl.c +6 -3
index 315d43d..69babbf 100644
@@ -3224,14 +3224,17 @@ int main(int argc, char **argv, char **envp)
                     exit(1);
                 }
                 break;
-#ifdef CONFIG_LIBISCSI
             case QEMU_OPTION_iscsi:
-                opts = qemu_opts_parse(qemu_find_opts("iscsi"), optarg, 0);
+                olist = qemu_find_opts("iscsi");
+                if (!olist) {
+                    fprintf(stderr, "iscsi is not supported by this qemu build.\n");
+                    exit(1);
+                }
+                opts = qemu_opts_parse(olist, optarg, 0);
                 if (!opts) {
                     exit(1);
                 }
                 break;
-#endif
 #ifdef CONFIG_SLIRP
             case QEMU_OPTION_tftp:
                 legacy_tftp_prefix = optarg;
Signature · 1 line
1.7.9.5
#2 lore raw

Re: [Qemu-devel] [PATCH 2/2] vl.c: throw an error if iscsi is not supported

Quoted 7 lines · Peter Lieven

this patch adds a check for qemu_find_opts("iscsi") returning NULL instead of blindly passing the result to qemu_opts_parse().

---
 vl.c |    9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)

Why is this change necessary?

Stefan

#3 lore raw

Re: [Qemu-devel] [PATCH 2/2] vl.c: throw an error if iscsi is not supported

Am 25.03.2013 um 15:00 schrieb Stefan Hajnoczi <[email protected]>:

Quoted 10 lines · Peter Lieven
Quoted 7 lines

this patch adds a check for qemu_find_opts("iscsi") returning NULL instead of blindly passing the result to qemu_opts_parse().

---
vl.c | 9 ++++++---

1 file changed, 6 insertions(+), 3 deletions(-)

Why is this change necessary?

a) just to make sure we check the result of qemu_find_opts for NULL in case a bug stops registering the opts again
b) to have an error output if libiscsi is not compiled in and someone passes an iscsi flag (analogue to the error if you supply -spice XXX)

Peter

Quoted 2 lines

Stefan

#4 lore raw

Re: [Qemu-devel] [PATCH 2/2] vl.c: throw an error if iscsi is not supported

Quoted 10 lines · Peter Lieven

Am 25.03.2013 um 15:00 schrieb Stefan Hajnoczi <[email protected]>:

Quoted 9 lines · Peter Lieven
Quoted 7 lines

this patch adds a check for qemu_find_opts("iscsi") returning NULL instead of blindly passing the result to qemu_opts_parse().

---
vl.c | 9 ++++++---

1 file changed, 6 insertions(+), 3 deletions(-)
Quoted 4 lines
Quoted 1 line

Why is this change necessary?

a) just to make sure we check the result of qemu_find_opts for NULL in case a bug stops registering the opts again

It's OK to crash for "can't happen" cases IMHO.

Quoted 2 lines

b) to have an error output if libiscsi is not compiled in and someone passes an iscsi flag (analogue to the error if you supply -spice XXX)

I don't have a strong opinion here but it would be good to be consistent. At the moment (as well as iscsi) SLIRP, TPM and mem_prealloc options all just vanish if qemu wasn't configured with them supported. [Various other things like SDL and Windows specific options do remain to produce an error.] So maybe we should move all these options to "always exist but may produce an error".

-- PMM

#5 lore raw

Re: [Qemu-devel] [PATCH 2/2] vl.c: throw an error if iscsi is not supported

Quoted 21 lines · Peter Maydell
Quoted 10 lines · Peter Lieven

Am 25.03.2013 um 15:00 schrieb Stefan Hajnoczi <[email protected]>:

Quoted 9 lines · Peter Lieven
Quoted 7 lines

this patch adds a check for qemu_find_opts("iscsi") returning NULL instead of blindly passing the result to qemu_opts_parse().

---
vl.c | 9 ++++++---

1 file changed, 6 insertions(+), 3 deletions(-)
Quoted 4 lines
Quoted 1 line

Why is this change necessary?

a) just to make sure we check the result of qemu_find_opts for NULL in case a bug stops registering the opts again

It's OK to crash for "can't happen" cases IMHO.

Quoted 2 lines

b) to have an error output if libiscsi is not compiled in and someone passes an iscsi flag (analogue to the error if you supply -spice XXX)

Quoted 7 lines

I don't have a strong opinion here but it would be good to be consistent. At the moment (as well as iscsi) SLIRP, TPM and mem_prealloc options all just vanish if qemu wasn't configured with them supported. [Various other things like SDL and Windows specific options do remain to produce an error.] So maybe we should move all these options to "always exist but may produce an error".

Agreed. Either this patch should be dropped because it's not strictly necessary. Or we should be consistent and clean up all of vl.c:main(). There's not much point of just changing -iscsi.

Stefan

#6 lore raw
In reply to Peter Lieven
Quoted 5 lines · Peter Lieven

commit 4d454574 "qemu-option: move standard option definitions out of qemu-config.c" broke support for commandline option groups that where registered during bdrv_init(). In particular support for -iscsi options was broken since that commit.

Quoted 7 lines

Fix by moving the bdrv_init_with_whitelist() before command line argument parsing.

---
 vl.c |    4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

Thanks, applied to my block tree:
https://github.com/stefanha/qemu/commits/block

vl.c int main(int argc, char **argv, char **envp) · line 2938

Quoted 9 lines
vl.c +1 -0
index aeed7f4..315d43d 100644
@@ -2935,6 +2935,8 @@ int main(int argc, char **argv, char **envp)
 
     nb_numa_nodes = 0;
     nb_nics = 0;
+    

I removed the trailing whitespace here. git-am(1) warns about it.