After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 743303 - Add spice+unix support
Add spice+unix support
Status: RESOLVED FIXED
Product: gnome-boxes
Classification: Applications
Component: spice
unspecified
Other All
: Normal normal
: 3.22
Assigned To: GNOME Boxes maintainer(s)
GNOME Boxes maintainer(s)
Depends on:
Blocks:
 
 
Reported: 2015-01-21 15:49 UTC by Marc-Andre Lureau
Modified: 2016-06-28 14:42 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
WIP: add spice+unix support (2.18 KB, patch)
2015-01-21 15:49 UTC, Marc-Andre Lureau
none Details | Review
spice-display: handle SPICE_CHANNEL_OPENED event (872 bytes, patch)
2016-04-25 16:32 UTC, Pavel Grunt
committed Details | Review
Add spice+unix support (1.97 KB, patch)
2016-04-25 16:36 UTC, Pavel Grunt
none Details | Review
spice-display: Be more strict when validating URI (1.06 KB, patch)
2016-04-26 14:14 UTC, Pavel Grunt
none Details | Review
Add spice+unix support (1.75 KB, patch)
2016-04-26 14:17 UTC, Pavel Grunt
none Details | Review
Add spice+unix support (1.73 KB, patch)
2016-04-26 17:24 UTC, Pavel Grunt
committed Details | Review
spice-display: Be more strict when validating URI (2.01 KB, patch)
2016-04-28 14:21 UTC, Pavel Grunt
none Details | Review
spice-display: Be more strict when validating URI (2.01 KB, patch)
2016-05-13 08:04 UTC, Pavel Grunt
none Details | Review
Use URL in strings instead of URI (7.18 KB, patch)
2016-05-13 08:05 UTC, Pavel Grunt
none Details | Review
Use URL in strings instead of URI (7.17 KB, patch)
2016-05-18 12:32 UTC, Pavel Grunt
committed Details | Review
spice-display: Be more strict when validating URI (2.01 KB, patch)
2016-05-18 12:33 UTC, Pavel Grunt
committed Details | Review

Description Marc-Andre Lureau 2015-01-21 15:49:12 UTC
Spice-gtk will allow connection to UNIX socket server, the patches are
under review for spice-gtk atm. Let's teach Boxes to deal with
spice+unix:// URI.
Comment 1 Marc-Andre Lureau 2015-01-21 15:49:15 UTC
Created attachment 295111 [details] [review]
WIP: add spice+unix support
Comment 2 Zeeshan Ali 2015-02-23 18:15:34 UTC
(In reply to Marc-Andre Lureau from comment #1)
> Created attachment 295111 [details] [review] [review]
> WIP: add spice+unix support

Doesn't bug#738573 make this obsolete?
Comment 3 Marc-Andre Lureau 2015-11-13 15:58:34 UTC
(In reply to Zeeshan Ali (Khattak) from comment #2)
> (In reply to Marc-Andre Lureau from comment #1)
> > Created attachment 295111 [details] [review] [review] [review]
> > WIP: add spice+unix support
> 
> Doesn't bug#738573 make this obsolete?

not fully, Boxes should still allow you to add "remote" VMs with spice+unix (VM not managed by libvirt in this case)

please apply
Comment 4 Zeeshan Ali 2015-11-13 18:30:56 UTC
(In reply to Marc-Andre Lureau from comment #3)
> (In reply to Zeeshan Ali (Khattak) from comment #2)
> > (In reply to Marc-Andre Lureau from comment #1)
> > > Created attachment 295111 [details] [review] [review] [review] [review]
> > > WIP: add spice+unix support
> > 
> > Doesn't bug#738573 make this obsolete?
> 
> not fully, Boxes should still allow you to add "remote" VMs with spice+unix
> (VM not managed by libvirt in this case)

Ah ok.

> please apply

You want me to apply a patch author marked as 'WIP'? :) I'll look into it soon..
Comment 5 Pavel Grunt 2016-04-25 08:48:51 UTC
I tested the patch (it applies cleanly), it allows to connect to vms created by qemu, eg: qemu-kvm -spice disable-ticketing,unix,addr=/tmp/spice.sock
Comment 6 Zeeshan Ali 2016-04-25 13:58:11 UTC
(In reply to Pavel Grunt from comment #5)
> I tested the patch (it applies cleanly), it allows to connect to vms created
> by qemu, eg: qemu-kvm -spice disable-ticketing,unix,addr=/tmp/spice.sock

Cool, thanks. Could you please also update the patch?
Comment 7 Zeeshan Ali 2016-04-25 13:58:39 UTC
(In reply to Zeeshan Ali (Khattak) from comment #6)
> (In reply to Pavel Grunt from comment #5)
> > I tested the patch (it applies cleanly), it allows to connect to vms created
> > by qemu, eg: qemu-kvm -spice disable-ticketing,unix,addr=/tmp/spice.sock
> 
> Cool, thanks. Could you please also update the patch?

At least commit log needs updating and we gotta remove the "WIP" tag. :)
Comment 8 Pavel Grunt 2016-04-25 16:32:26 UTC
Created attachment 326702 [details] [review]
spice-display: handle SPICE_CHANNEL_OPENED event

Do not log a debug message, the event is expected.

Splitted from the original patch
Comment 9 Pavel Grunt 2016-04-25 16:36:15 UTC
Created attachment 326704 [details] [review]
Add spice+unix support

changes since WIP:
* channel event handling moved to separated patch
* added check in spice_validate_uri(), otherwise an uri like "spice+anything://host:port" would be valid
Comment 10 Pavel Grunt 2016-04-25 16:38:49 UTC
(In reply to Pavel Grunt from comment #9)
> Created attachment 326704 [details] [review] [review]
sorry, it should obsolete the original patch, not the patch from the comment 8
Comment 11 Zeeshan Ali 2016-04-25 17:47:36 UTC
Review of attachment 326702 [details] [review]:

ack
Comment 12 Zeeshan Ali 2016-04-25 18:01:19 UTC
Review of attachment 326704 [details] [review]:

good otherwise.

::: src/spice-display.vala
@@ +558,3 @@
+            (uri.query_raw ?? uri.query) != null)
+            throw new Boxes.Error.INVALID (_("Invalid Spice UNIX URI"));
+    } else if (uri.scheme.has_prefix("spice+")) {

Don't think you need to explicitly check for this specific case. How about this:

 if (uri.scheme == "spice+unix") {
  ...
 } else if (port <= 0 && tls_port <= 0) {
  ...
 } else {
   throw new Boxes.Error.INVALID (_("Invalid URI"));
 }

::: src/wizard.vala
@@ +326,2 @@
             spice_validate_uri (uri_as_text);
+            source.source_type = "spice";

i'm guessing this is needed now because source_type is assumed to be same as URI scheme if not explicitly set?
Comment 13 Pavel Grunt 2016-04-25 18:15:42 UTC
Review of attachment 326704 [details] [review]:

::: src/spice-display.vala
@@ +558,3 @@
+            (uri.query_raw ?? uri.query) != null)
+            throw new Boxes.Error.INVALID (_("Invalid Spice UNIX URI"));
+    } else if (uri.scheme.has_prefix("spice+")) {

you need to check for invalid scheme before checking invalid port. The way you suggested "spice+anything://host:port" would be valid

::: src/wizard.vala
@@ +326,2 @@
             spice_validate_uri (uri_as_text);
+            source.source_type = "spice";

So it would be "spice+unix", which is not valid, no?
Comment 14 Zeeshan Ali 2016-04-26 13:34:49 UTC
Review of attachment 326704 [details] [review]:

::: src/spice-display.vala
@@ +558,3 @@
+            (uri.query_raw ?? uri.query) != null)
+            throw new Boxes.Error.INVALID (_("Invalid Spice UNIX URI"));
+    } else if (uri.scheme.has_prefix("spice+")) {

true. I think you want to check for all invalid URIs then, not just for some specific kind:

switch (uri.scheme) {
   case "spice+unix":
     ..
     break;

   case "spice:"
     if (port <= 0 && tls_port <= 0) {
     ...
     }
     break;

   default:
     throw new Boxes.Error.INVALID (_("Invalid URI"));     
     break;
}

::: src/wizard.vala
@@ +326,2 @@
             spice_validate_uri (uri_as_text);
+            source.source_type = "spice";

yes.
Comment 15 Pavel Grunt 2016-04-26 14:14:32 UTC
Created attachment 326780 [details] [review]
spice-display: Be more strict when validating URI

Throw an error if the URI scheme is invalid.
Comment 16 Pavel Grunt 2016-04-26 14:17:11 UTC
Created attachment 326781 [details] [review]
Add spice+unix support

Spice-gtk allows to connect to a UNIX socket server since v0.28.
Let's teach Boxes to deal with spice+unix:// URI.

changes:
"if" to "case" due to the new patch "spice-display: Be more strict when validating URI"
Comment 17 Zeeshan Ali 2016-04-26 16:17:27 UTC
Review of attachment 326780 [details] [review]:

Good call separateing out this change.

::: src/spice-display.vala
@@ +557,3 @@
+    case "spice":
+        if (port <= 0 && tls_port <= 0)
+            throw new Boxes.Error.INVALID (_("Missing port in Spice URI"));

We might take this opportunity and fix this translated message a bit: "Missing port in SPICE URL" since SPICE is correct way of putting it and we used the terms SPICE and URL in the UI. But i guess you'll want to put that in a seperate patch that goes before this one.

@@ +560,3 @@
+        break;
+    default:
+        throw new Boxes.Error.INVALID (_("Invalid URI"));

URL in here too.
Comment 18 Zeeshan Ali 2016-04-26 16:24:05 UTC
Review of attachment 326781 [details] [review]:

Nitpick on description part of commit log: Each line is supposed to be 74 characters, breaking it before that limit exceeds makes it look like you are starting a new para but without empty line between two paras.

::: src/spice-display.vala
@@ +561,3 @@
+    case "spice+unix":
+        if (port > 0 ||
+            (uri.query_raw ?? uri.query) != null)

Use of ?? operator here only makes it less readable.

if (port > 0 || uri.query_raw != null || uri.query != null)

would be more readable IMO. BTW, in Boxes code, the lines are 120 columns so no need to break the condition into multiple lines here.

@@ +562,3 @@
+        if (port > 0 ||
+            (uri.query_raw ?? uri.query) != null)
+            throw new Boxes.Error.INVALID (_("Invalid Spice UNIX URI"));

Don't think we need to tell user that it's a UNIX URL, let's just re-use the generic error here.

::: src/wizard.vala
@@ +323,3 @@
         source = new CollectionSource (uri.server ?? uri_as_text, uri.scheme, uri_as_text);
 
+        if (uri.scheme == "spice" || uri.scheme.has_prefix("spice+")) {

why check of prefix and not just "spice+unix" scheme?
Comment 19 Pavel Grunt 2016-04-26 16:57:43 UTC
Review of attachment 326780 [details] [review]:

::: src/spice-display.vala
@@ +557,3 @@
+    case "spice":
+        if (port <= 0 && tls_port <= 0)
+            throw new Boxes.Error.INVALID (_("Missing port in Spice URI"));

I would say it is a different bug - I guess you'll want to change all the strings (grep shows that URI is used in strings in app.vala, libvirt-machine-properties.vala, ovirt-machine.vala, vnc-display.vala...)
Comment 20 Zeeshan Ali 2016-04-26 17:13:14 UTC
Review of attachment 326780 [details] [review]:

::: src/spice-display.vala
@@ +557,3 @@
+    case "spice":
+        if (port <= 0 && tls_port <= 0)
+            throw new Boxes.Error.INVALID (_("Missing port in Spice URI"));

Ah ok, I did not realize but I don't think this small change justifies creating another bug.
Comment 21 Pavel Grunt 2016-04-26 17:24:09 UTC
Created attachment 326794 [details] [review]
Add spice+unix support

changes:
 line break around 74 characters in the commit message
 removed usage of the '??' operator
 reused the generic error message
 explicit check for the scheme instead of prefix
Comment 22 Zeeshan Ali 2016-04-28 13:57:20 UTC
Ouch, I pushed these patches by mistake while pushing the patch for bug#723008. :(

Pavel, sorry you'll have to rebase your patches now. :(

Attachment 326702 [details] pushed as 62f211b - spice-display: handle SPICE_CHANNEL_OPENED event
Attachment 326794 [details] pushed as e1fa2e0 - Add spice+unix support
Comment 23 Zeeshan Ali 2016-04-28 14:09:58 UTC
(In reply to Zeeshan Ali (Khattak) from comment #22)
> Ouch, I pushed these patches by mistake while pushing the patch for
> bug#723008. :(

Err. I'm on a roll today. I meant bug#763772.
Comment 24 Pavel Grunt 2016-04-28 14:21:33 UTC
Created attachment 326944 [details] [review]
spice-display: Be more strict when validating URI

rebased, checking for the prefix of the scheme in wizard is enough as the full scheme is validated in spice_validate_uri()
Comment 25 Zeeshan Ali 2016-05-04 18:06:30 UTC
I mean, could you please fix all the issue pointed out in all patches, including the committed ones? For committed patches, you'd obviously need to fix the issues in new patches. Sorry for the mess again.
Comment 26 Pavel Grunt 2016-05-04 18:22:19 UTC
(In reply to Zeeshan Ali (Khattak) from comment #25)
> I mean, could you please fix all the issue pointed out in all patches,
> including the committed ones? For committed patches, you'd obviously need to
> fix the issues in new patches. Sorry for the mess again.

Sorry, I don't know what is not fixed by the patch in the comment 24.
Comment 27 Zeeshan Ali 2016-05-04 18:42:02 UTC
Review of attachment 326944 [details] [review]:

::: src/spice-display.vala
@@ +557,3 @@
+    case "spice+unix":
+        if (port > 0 || uri.query_raw != null || uri.query != null)
+            throw new Boxes.Error.INVALID (_("Invalid URI"));

As we discussed, this should be "URL", not "URI". You informed me that "URI" is already being used in these translated messages so I asked if you could kindly change them (in a separate change) first.
Comment 28 Pavel Grunt 2016-05-04 19:25:28 UTC
(In reply to Zeeshan Ali (Khattak) from comment #27)
> Review of attachment 326944 [details] [review] [review]:
> 
> ::: src/spice-display.vala
> @@ +557,3 @@
> +    case "spice+unix":
> +        if (port > 0 || uri.query_raw != null || uri.query != null)
> +            throw new Boxes.Error.INVALID (_("Invalid URI"));
> 
> As we discussed, this should be "URL", not "URI". You informed me that "URI"
> is already being used in these translated messages so I asked if you could
> kindly change them (in a separate change) first.

We did not discuss about it, I don't know why it is wrong. Actually in comment 20 you were ok with my suggestion that it is a different bug - if you do not want to open bug for it, I can do it for you :)

Currently URI is used everywhere, URL is used in 2 strings. I don't know why now you don't like URI. gtk has function gtk_show_uri, wizard has method open_with_uri, many variables have uri in their name. In my opinion this mass rename (~140 occurrences of uri) does not fit to this bug...
Comment 29 Zeeshan Ali 2016-05-05 11:39:25 UTC
(In reply to Pavel Grunt from comment #28)
> (In reply to Zeeshan Ali (Khattak) from comment #27)
> > Review of attachment 326944 [details] [review] [review] [review]:
> > 
> > ::: src/spice-display.vala
> > @@ +557,3 @@
> > +    case "spice+unix":
> > +        if (port > 0 || uri.query_raw != null || uri.query != null)
> > +            throw new Boxes.Error.INVALID (_("Invalid URI"));
> > 
> > As we discussed, this should be "URL", not "URI". You informed me that "URI"
> > is already being used in these translated messages so I asked if you could
> > kindly change them (in a separate change) first.
> 
> We did not discuss about it, I don't know why it is wrong. Actually in
> comment 20 you were ok with my suggestion that it is a different bug - if
> you do not want to open bug for it, I can do it for you :)

No, I said the change doesn't justify a bug but if you prefer another bug, please do create another one and put the patch in there.

My point was that just because some existing strings are the wrong way, doesn't mean we should add to that but rather fix those strings first.

> Currently URI is used everywhere, URL is used in 2 strings. I don't know why
> now you don't like URI. gtk has function gtk_show_uri, wizard has method
> open_with_uri, many variables have uri in their name. In my opinion this
> mass rename (~140 occurrences of uri) does not fit to this bug...

There is a reason why I included the term "translated". We can call it URI or uri in the code and that is all fine, I was talking of user-visible strings. See the URL entry page of wizard and you'll see we call it URL in labels so I want to be consistent with that: User is asked to enter a URL and then if it's incorrect URL, they get an error talking about URI.
Comment 30 Pavel Grunt 2016-05-13 08:04:47 UTC
Created attachment 327757 [details] [review]
spice-display: Be more strict when validating URI

Throw an error if the URI scheme is invalid.
Comment 31 Pavel Grunt 2016-05-13 08:05:56 UTC
Created attachment 327758 [details] [review]
Use URL in strings instead of URI
Comment 32 Zeeshan Ali 2016-05-18 11:46:28 UTC
Review of attachment 327757 [details] [review]:

Sorry to come to this review so late but it probably needs a rebase now, cause git(-bz) dies on this:

Applying: spice-display: Be more strict when validating URI
fatal: sha1 information is lacking or useless (src/spice-display.vala).
Repository lacks necessary blobs to fall back on 3-way merge.
Cannot fall back to three-way merge.
Patch failed at 0001 spice-display: Be more strict when validating URI
The copy of the patch that failed is found in:
   /home/zeenix/checkout/gnome/gnome-boxes/.git/rebase-apply/patch
When you have resolved this problem run "git bz apply --continue".
If you would prefer to skip this patch, instead run "git bz apply --skip".
To restore the original branch and stop patching run "git bz apply --abort".
Patch left in /tmp/spice-display-Be-more-strict-when-validating-URI-sB__kW.patch
Comment 33 Pavel Grunt 2016-05-18 12:32:55 UTC
Created attachment 328134 [details] [review]
Use URL in strings instead of URI
Comment 34 Pavel Grunt 2016-05-18 12:33:00 UTC
Created attachment 328135 [details] [review]
spice-display: Be more strict when validating URI

Throw an error if the URI scheme is invalid.
Comment 35 Zeeshan Ali 2016-05-18 13:35:03 UTC
Review of attachment 328134 [details] [review]:

A bit of detail in commit log would be nice.
Comment 36 Zeeshan Ali 2016-05-18 13:38:07 UTC
Review of attachment 328135 [details] [review]:

The commit log (the you re-used from an already commit patch) is not correct summary of this change. Please update.
Comment 37 Pavel Grunt 2016-05-18 14:26:18 UTC
Review of attachment 328135 [details] [review]:

Please tell from which commit I reused it. Anyway it is correct, currently it is not strict - it is allowed to use spice+unix://socket:port. This patch avoids it by strictly checking for the uri scheme. Without this patch no error is emitted, this patch changes it, so the error is emitted.
Comment 38 Zeeshan Ali 2016-05-18 15:35:14 UTC
Review of attachment 328135 [details] [review]:

Ah, my mess-up was even messier than I thought. I was talking of this patch: https://bugzilla.gnome.org/attachment.cgi?id=326780&action=diff

which it turns out, was not the one that I applied (accidently) but the earlier patch "Add spice+unix support", which contained these changes. :(
Comment 39 Zeeshan Ali 2016-06-28 14:41:58 UTC
Attachment 328134 [details] pushed as a01f426 - Use URL in strings instead of URI
Attachment 328135 [details] pushed as e04de70 - spice-display: Be more strict when validating URI