Skip to contentSkip to conversation

Disallow colons in the parameter of "-accel"

PATCH Superseded Thomas Huth 3 participants 5 messages Sep 23, 2019

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Disallow colons in the parameter of "-accel"

Everybody who used something like "-machine accel=kvm:tcg" in the past might be tempted to specify a similar list with the -accel parameter, too, for example "-accel kvm:tcg". However, this is not how this options is thought to be used, since each "-accel" should only take care of one specific accelerator.

In the long run, we really should rework the "-accel" code completely, so that it does not set "-machine accel=..." anymore internally, but is completely independent from "-machine". For the short run, let's make sure that users cannot use "-accel xyz:tcg", so that we avoid that we have to deal with such cases in the wild later.

---
 vl.c | 5 +++++
 1 file changed, 5 insertions(+)
vl.c +5 -0
index 630f5c5e9c..68f47a9c25 100644
@@ -3554,6 +3554,11 @@ int main(int argc, char **argv, char **envp)
                     g_slist_free(accel_list);
                     exit(0);
                 }
+                if (optarg && strchr(optarg, ':')) {
+                    error_report("Don't use ':' with -accel, "
+                                 "use -M accel=... in this case instead");
+                    exit(1);
+                }
                 opts = qemu_opts_create(qemu_find_opts("machine"), NULL,
                                         false, &error_abort);
                 qemu_opt_set(opts, "accel", optarg, &error_abort);
Signature · 1 line
2.18.1
#1 lore raw
Quoted 23 lines · Thomas Huth

Everybody who used something like "-machine accel=kvm:tcg" in the past might be tempted to specify a similar list with the -accel parameter, too, for example "-accel kvm:tcg". However, this is not how this options is thought to be used, since each "-accel" should only take care of one specific accelerator.

In the long run, we really should rework the "-accel" code completely, so that it does not set "-machine accel=..." anymore internally, but is completely independent from "-machine". For the short run, let's make sure that users cannot use "-accel xyz:tcg", so that we avoid that we have to deal with such cases in the wild later.

---
 vl.c | 5 +++++
 1 file changed, 5 insertions(+)
vl.c +0 -0
index 630f5c5e9c..68f47a9c25 100644

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

Quoted 8 lines
vl.c +5 -0
@@ -3554,6 +3554,11 @@ int main(int argc, char **argv, char **envp)
                     g_slist_free(accel_list);
                     exit(0);
                 }
+                if (optarg && strchr(optarg, ':')) {
+                    error_report("Don't use ':' with -accel, "
+                                 "use -M accel=... in this case instead");
+                    exit(1);
+                }

This seems pretty ugly. If -accel is the way we're recommending users configure the accelerator then it should support syntax for specifying everything we could do with the old -machine... option. If it can't do that yet, we shouldn't switch over to it until it can.

thanks
-- PMM

#2 lore raw
Quoted 19 lines · Peter Maydell
Quoted 18 lines · Thomas Huth

Everybody who used something like "-machine accel=kvm:tcg" in the past might be tempted to specify a similar list with the -accel parameter, too, for example "-accel kvm:tcg". However, this is not how this options is thought to be used, since each "-accel" should only take care of one specific accelerator.

In the long run, we really should rework the "-accel" code completely, so that it does not set "-machine accel=..." anymore internally, but is completely independent from "-machine". For the short run, let's make sure that users cannot use "-accel xyz:tcg", so that we avoid that we have to deal with such cases in the wild later.

---
 vl.c | 5 +++++
 1 file changed, 5 insertions(+)
Quoted 15 lines

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

Quoted 13 lines
vl.c +5 -0
index 630f5c5e9c..68f47a9c25 100644
@@ -3554,6 +3554,11 @@ int main(int argc, char **argv, char **envp)
                     g_slist_free(accel_list);
                     exit(0);
                 }
+                if (optarg && strchr(optarg, ':')) {
+                    error_report("Don't use ':' with -accel, "
+                                 "use -M accel=... in this case instead");
+                    exit(1);
+                }

This seems pretty ugly.

Yes. The whole "-accel" option is currently ugly. My patch is just a temporary work-around to prevent that we later have to deal with the fact that users started to use this colon here in the wild and we would then have to fight to get rid of it again.

Quoted 4 lines

If -accel is the way we're recommending
users configure the accelerator then it should support syntax for specifying everything we could do with the old -machine... option.

No, we certainly don't want to have the colon in here. The idea is rather that you could specify multiply "-accel" options one day, e.g.:

-accel tcg,tb-size=2048 -accel kvm,kernel_irqchip=on

... and then the accelators are used with the right parameters in the order of availability.

Per-accelerator parameters just don't work here if you allow the colon.

(IMHO we should not have let the -accel code enter the repository in this shape, but rather insist on a proper implementation right from the start - but now that it's there, we have to deal with it and should make sure that it does not get worse)

Thomas

#3 lore raw
Quoted 22 lines · Thomas Huth
Quoted 1 line · Peter Maydell

This seems pretty ugly.

Yes. The whole "-accel" option is currently ugly. My patch is just a temporary work-around to prevent that we later have to deal with the fact that users started to use this colon here in the wild and we would then have to fight to get rid of it again.

Quoted 4 lines

If -accel is the way we're recommending
users configure the accelerator then it should support syntax for specifying everything we could do with the old -machine... option.

No, we certainly don't want to have the colon in here. The idea is rather that you could specify multiply "-accel" options one day, e.g.:

-accel tcg,tb-size=2048 -accel kvm,kernel_irqchip=on

... and then the accelators are used with the right parameters in the order of availability.

Quoted 6 lines

Per-accelerator parameters just don't work here if you allow the colon.

(IMHO we should not have let the -accel code enter the repository in this shape, but rather insist on a proper implementation right from the start - but now that it's there, we have to deal with it and should make sure that it does not get worse)

Ah, I hadn't realised that -accel was a (relatively) long-standing option; I'd just noticed some patches going past recently suggesting we were starting to recommend it over -machine accel=. Thanks for trying to clean it up a bit.

-- PMM

#4 lore raw
In reply to Thomas Huth
Quoted 22 lines · Thomas Huth

Everybody who used something like "-machine accel=kvm:tcg" in the past might be tempted to specify a similar list with the -accel parameter, too, for example "-accel kvm:tcg". However, this is not how this options is thought to be used, since each "-accel" should only take care of one specific accelerator.

In the long run, we really should rework the "-accel" code completely, so that it does not set "-machine accel=..." anymore internally, but is completely independent from "-machine". For the short run, let's make sure that users cannot use "-accel xyz:tcg", so that we avoid that we have to deal with such cases in the wild later.

---
 vl.c | 5 +++++
 1 file changed, 5 insertions(+)
vl.c +0 -0
index 630f5c5e9c..68f47a9c25 100644

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

Quoted 6 lines
vl.c +3 -0
@@ -3554,6 +3554,11 @@ int main(int argc, char **argv, char **envp)
                     g_slist_free(accel_list);
                     exit(0);
                 }
+                if (optarg && strchr(optarg, ':')) {
+                    error_report("Don't use ':' with -accel, "
+                                 "use -M accel=... in this case instead");

s/in this case/for now/ or something like that?

Thanks,

Paolo

Quoted 6 lines
vl.c +2 -0
+                    exit(1);
+                }
                 opts = qemu_opts_create(qemu_find_opts("machine"), NULL,
                                         false, &error_abort);
                 qemu_opt_set(opts, "accel", optarg, &error_abort);