GNOME Bugzilla – Bug 736917
support starting of a VM by domain name through commandline
Last modified: 2018-01-11 10:11:19 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`
(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.
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
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?
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?
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'
btw `gnome-boxes --open-uuid` already works
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 :)
-- 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.