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 736917 - support starting of a VM by domain name through commandline
support starting of a VM by domain name through commandline
Status: RESOLVED OBSOLETE
Product: gnome-boxes
Classification: Applications
Component: general
3.13.x
Other All
: Normal minor
: --
Assigned To: GNOME Boxes maintainer(s)
GNOME Boxes maintainer(s)
Depends on:
Blocks:
 
 
Reported: 2014-09-18 15:57 UTC by Lasse Schuirmann
Modified: 2018-01-11 10:11 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
Draft (3.92 KB, patch)
2017-07-07 14:52 UTC, Thiago
none Details | Review

Description Lasse Schuirmann 2014-09-18 15:57:28 UTC
It has been asked for on the mailing list, would be easy and handy if Boxes would support direct starting of a VM via: `gnome-boxes vm_name`
Comment 1 Zeeshan Ali 2014-09-29 12:31:38 UTC
(In reply to comment #0)
> It has been asked for on the mailing list, would be easy and handy if Boxes
> would support direct starting of a VM via: `gnome-boxes vm_name`

Its kind already in place but currently we only support title. Should be trivial to fix.
Comment 2 Felipe Borges 2017-07-03 10:04:11 UTC
As a tip to newcomers working on this bug, see:

  * https://wiki.gnome.org/HowDoI/GtkApplication/CommandLine
  * https://git.gnome.org/browse/gnome-boxes/tree/src/app.vala#n183
Comment 3 Thiago 2017-07-03 16:02:50 UTC
Wondering here.

I have a few virtual machines here and all of them has a long name like

1) Windows 7 Ultimate SP1 (32 Bit)
2) Windows 8
3) Kali Linux
4) Arch Linux
5) Fedora Linux

I could add the command line option "--run vm_name" but I think it would be to long.

So my idea would be to have a --list to list all the virtual machines. The output would be something like:

#1 Windows 7 Ultimate SP1 (32 Bit)
#2 Windows 8
#3 Kali Linux
#4 Arch Linux
#5 Fedora Linux

and another command line for the run command that would be something like

gnome-boxes --run 1 - to run Windows 7 Ultimate SP1 (32 Bit)
gnome-boxes --run 5 - to Fedora Linux

Any better ideas? Shall I stick to the long name instead?
Comment 4 Thiago 2017-07-04 21:35:21 UTC
This is one solution:

gnome-boxes --run "Virtual Machine Name"

ir this Virtual Machine name does not exists the user will get the app running as normal but it will be possible to see the next message if the user checks the console:

➜  src git:(bug/736917) ✗ ./gnome-boxes --run "virtual name that not exists"

Can't find the virtual machine: 'virtual name that not exists'

List of virtual machines to run:
#0 - Windows 7 Ultimate SP1 (32 Bit)
#1 - Kali Linux
#2 - Slackware Linux
#3 - ArchLinux
#5 - Fedora 25 Linux

Any better idea?
Comment 5 Pavel Grunt 2017-07-07 07:00:39 UTC
Hi Thiago,

I'd drop the '--run' (consider that the VM may be running)

It should be possible to find VMs by their name (gvir_connection_find_domain_by_name) by id (gvir_connection_find_domain_by_id) and also by uuid.

The 'id' is related to already running VMs (can be different everytime).

Take a look at `virsh start` command, it supports starting the domain name by the 'name' and 'uuid'
Comment 6 Pavel Grunt 2017-07-07 07:11:11 UTC
btw `gnome-boxes --open-uuid` already works
Comment 7 Thiago 2017-07-07 14:52:57 UTC
Created attachment 355097 [details] [review]
Draft

there is a virsh list to tell me which (In reply to Pavel Grunt from comment #5)
> Hi Thiago,
> 
> I'd drop the '--run' (consider that the VM may be running)

Good. That's make a lot of sense :D

> 
> It should be possible to find VMs by their name
> (gvir_connection_find_domain_by_name) by id
> (gvir_connection_find_domain_by_id) and also by uuid.
> 

What I did here using the function we find in the code already is:

commandline: gnome-boxes --open-name "abc"
------------------------------------------------------------
➜  src git:(bug/736917) ✗ gnome-boxes --open-name "abc"

Can't find the virtual machine: 'abc'
List of virtual machines to run:

-> Windows 7 Ultimate SP1 (32 Bit)
------------------------------------------------------------
--> In this case there is no virtual machine using the name "abc" so
the app will run but it will also show a message on the console telling
the user what happened.


commandline: gnome-boxes --open-name "Windows 7 Ultimate SP1 (32 Bit)"
Sucess:
------------------------------------------------------------
➜  src git:(bug/736917) ✗ gnome-boxes --open-name "Windows 7 Ultimate SP1 (32 Bit)"
------------------------------------------------------------
--> In this case the "Windows 7 Ultimate SP1 (32 Bit) will run.

But I can change everything.

> The 'id' is related to already running VMs (can be different everytime).
> 
> Take a look at `virsh start` command, it supports starting the domain name
> by the 'name' and 'uuid'

checking the virsh commandline I can see there is also a 'virsh list' to tell me the virtual machines I have. After that I just run virsh reboot/shutdown/suspend/resume virtual_machine_name. Sounds great. Shall we have the "list" command too or is it enought the way I'm doing it here? Shall I change my approach?

I'm attaching a patch so if you like you can have a better idea of what I have here.

Thanks Pavel for your time and your help :)
Comment 8 GNOME Infrastructure Team 2018-01-11 10:11:19 UTC
-- GitLab Migration Automatic Message --

This bug has been migrated to GNOME's GitLab instance and has been closed from further activity.

You can subscribe and participate further through the new bug through this link to our GitLab instance: https://gitlab.gnome.org/GNOME/gnome-boxes/issues/33.